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 can I do graphics in c?

0 Answers  


1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)

12 Answers   Eskom, TCS,


Differentiate between new and malloc(), delete and free() ?

0 Answers   iNautix,


#&#8206;include&#8236;<stdio.h> void main() { int i; for(i=5;0;i++) { printf("%d",i); } }

2 Answers   Facebook,


What is null pointer constant?

0 Answers  






why TCS selected more student in the software field from all institution.

5 Answers   TCS,


Why double pointer is used in c?

0 Answers  


What is hashing in c language?

0 Answers  


what is the difference between while and do while?

2 Answers  


n=7623 { temp=n/10; result=temp*10+ result; n=n/10 }

7 Answers   Wipro,


What is hungarian notation? Is it worthwhile?

0 Answers  


Explain low-order bytes.

0 Answers  


Categories