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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is it usually a bad idea to use gets()? Suggest a workaround.

906


Why static variable is used in c?

557


Once I have used freopen, how can I get the original stdout (or stdin) back?

628


What is dynamic dispatch in c++?

558


How do you redirect a standard stream?

626






What is a memory leak? How to avoid it?

577


What is the significance of an algorithm to C programming?

596


What is the difference between formatted&unformatted i/o functions?

617


can anyone please tell about the nested interrupts?

1678


In C, What is the #line used for?

1062


How many parameters should a function have?

668


what is the difference between class and unio?

1862


Why c is called free form language?

572


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

641


What is double pointer?

560