0
Why the output is not correct in this C program?
#include <stdio.h> #include <stdlib.h> #include<string.h> //program to print the repetation of character in a string //string int main() { char str[20]; char c; printf("Enter string\t"); gets(str); int i; int length,flag=0; printf("\nEnter character to know its repetation\t"); scanf(" %c",&c); length=strlen(str); for(i=0;i<length;i++) { if(str[i]== c); { flag++; } } printf("\n %c REPEAT %d times ",c,flag); return 0; }
3 odpowiedzi
+ 2
You have semicolon after if statement, which causes the if statement useless.
0
Ohh thanks