Displaying ./code/sternflCode/str4.c#include<stdio.h>
#include<string.h>
//get a string from the user
//Count the number of X's in the string
int main() {
char st[200];
scanf("%s", st);
printf("%s\n", st);
int Xcount = 0;
for(int i=0; st[i]!=0; i++)
if (st[i]=='X')
Xcount++;
printf("The number of X's is %d\n", Xcount);
return 0;
}
|