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
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 |
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 |
how to multiply two number taking input as a string (considering sum and carry )
What is the condition that is applied with ?: Operator?
Why can't we initialise member variable of a strucutre
How many levels of pointers can you have?
Explain the differences between public, protected, private and internal.
How many loops are there in c?
The difference between printf and fprintf is ?
Is c call by value?
What is the use of header?
Explain what is the difference between functions abs() and fabs()?
What is a class c rental property?
What is type qualifiers?