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

write a 'c' program to sum the number of integer values

8 Answers  


a=(1,2,3); b=1,2,3; c=1,(2,3); d=(1,2),3; what's the value of 'a','b','c','d'

2 Answers  


what is Array?

3 Answers  


Who is the founder of c language?

0 Answers  


what is the difference between declaration ,defenetion and initialization of a variable?

7 Answers   LG Soft,






is forign key will be unique key any table or not?

2 Answers  


Is struct oop?

0 Answers  


What are the valid places to have keyword “break”?

0 Answers  


i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k);

8 Answers   HCL,


Explain what are linked list?

0 Answers  


from which concept of 'c', the static member function of 'c++' has came?

1 Answers   Bosch,


How are strings stored in c?

0 Answers  


Categories