c programing Write a program that needs 5 words and prints o


c programing

Write a program that needs 5 words and prints only those words that end with the letter \"d\". Enter five words: Test password program hold college Words that end with the letter d: password hold

Solution

#include <stdio.h>
#include<string.h>


int main()
{
char s[50][80], last = \' \', temp[80];
int line = 0, i;
  
printf(\"Number of values you want to enter\ \");
scanf(\"%d\",&line);
printf(\"enter %d values\ \",line);
for(i=0;i<line;i++)
{   
scanf(\"%s\", s[i]);
}
printf(\"\ Words that end with the letter d:\ \");
for(i=0;i<line;i++)
{   
strcpy(temp, s[i]);
last = temp[strlen(s[i]) - 1];
if(last == \'d\')
printf(\"%s\ \", s[i]);
  
}

return 0;
}

 c programing Write a program that needs 5 words and prints only those words that end with the letter \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site