write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
#include <stdio.h> int main() { char s[100], ch, temp; int i, count = 0; printf("Enter a letter: "); scanf ("%c", &ch); scanf ("%c", &temp); printf("Enter a sentence: "); scanf ("%[^\n]%*c", s); for(i = 0;s[i]!='\0';i++){ if(s[i]==ch){ count++; } } printf("%c occurred in the %s in %d times\n",ch,s,count); return 0; }
Get Answers For Free
Most questions answered within 1 hours.