Write a C program that reads a series of strings and prints
only those ending in "ed"

Answers were Sorted based on User's Feedback



Write a C program that reads a series of strings and prints only those ending in "ed"..

Answer / mani

#include<stdio.h>

main()
{

char *a[6]={"sayed","jhsdj","manvi","buged","error"};

int i,j,k,h;
int flag=0;

for(i=0;i<5;i++)
{
j=0;
j=strlen(a[i]);
if(*(a[i]+3)=='e'&& *(a[i]+4)=='d')
{
printf("%s\n",a[i]);
}
else
{
printf("no match\n");
}
}
}

Is This Answer Correct ?    11 Yes 11 No

Write a C program that reads a series of strings and prints only those ending in "ed"..

Answer / antony from chennai

void main()
{
char *s[10];
int n;
printf("No of strings:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%s",s[i]);
}
for(i=1;i<=n;i++)
{
int len;
len=strlen(*s[i]);
len=len-1;
if(*s[len]='e' && *s[len--]='d')
{
printf("%s",*s[i]);
}
else
{
printf("no match");
}
}
getch();
}
}

Is This Answer Correct ?    4 Yes 16 No

Post New Answer

More C Interview Questions

how to multiply two number taking input as a string (considering sum and carry )

2 Answers   Wipro,


What is the condition that is applied with ?: Operator?

0 Answers  


Why can't we initialise member variable of a strucutre

1 Answers  


How many levels of pointers can you have?

0 Answers  


Explain the differences between public, protected, private and internal.

2 Answers  






How many loops are there in c?

0 Answers  


The difference between printf and fprintf is ?

0 Answers   Baan Infotech,


Is c call by value?

0 Answers  


What is the use of header?

0 Answers  


Explain what is the difference between functions abs() and fabs()?

0 Answers  


What is a class c rental property?

0 Answers  


What is type qualifiers?

0 Answers  


Categories