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
How can you avoid including a header more than once?
Here is a neat trick for checking whether two strings are equal
What is the difference between int main and void main?
What is a char c?
program for reversing a selected line word by word when multiple lines are given without using strrev
In a header file whether functions are declared or defined?
Why is %d used in c?
What is scope rule in c?
What header files do I need in order to define the standard library functions I use?
Ow can I insert or delete a line (or record) in the middle of a file?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is difference between stdio h and conio h?
What is difference between static and global variable in c?
How would you obtain the current time and difference between two times?
Explain how does flowchart help in writing a program?