2) Type a program in the space given below to take a string input and print those words that starts with 'a' and ends with 'd'.Plz solve this asap i need help
Answers
Answered by
2
Input : geeks for geeks
Output :
geeks->5
for->3
geeks->5
Answered by
1
include
include
void main()
{
char test[30];
char first[5];
char last[5];
printf(“Enter a word:”);
scanf(“%s”,&test);
printf(“\nEnter the first letter in the word:”);
scanf(“%s”,&first);
printf(“\nEnter the last letter in the word:”);
scanf(“%s”,&last);
if(first=“a”||last=“d”);
printf(“\nThe word is :%s”,test);
printf(“\nThe first letter is %s\n The last letter is %s,first,last);
else
printf(“\ngiven word does not start with a and does not end with d”)
// not sure if this work as i am in mobile but this is the same structure which you can use to work on it
getch();
}
include
void main()
{
char test[30];
char first[5];
char last[5];
printf(“Enter a word:”);
scanf(“%s”,&test);
printf(“\nEnter the first letter in the word:”);
scanf(“%s”,&first);
printf(“\nEnter the last letter in the word:”);
scanf(“%s”,&last);
if(first=“a”||last=“d”);
printf(“\nThe word is :%s”,test);
printf(“\nThe first letter is %s\n The last letter is %s,first,last);
else
printf(“\ngiven word does not start with a and does not end with d”)
// not sure if this work as i am in mobile but this is the same structure which you can use to work on it
getch();
}
Similar questions