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

Is calloc better than malloc?

0 Answers  


what is the difference between static variable and register variable?

3 Answers  


what is void pointer?

1 Answers   Wipro,


Explain how do you convert strings to numbers in c?

0 Answers  


When is a “switch” statement preferable over an “if” statement?

0 Answers  


what defference between c and c++ ?

6 Answers  


Is it possible to run a c program without using main?If yes HOW??

13 Answers   Wipro,


What is #include in c?

0 Answers  


The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

0 Answers   Microsoft,


what is the use of fflush() function?

2 Answers  


what is the return type of printf

3 Answers  


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

0 Answers  


Categories