Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- int main()
- {
- char str[30], ch;
- int i, count=0;
- printf("Enter a string: ");
- scanf("%[^\n]%*c", &str);
- printf("\nEnter character to be searched: ");
- scanf("%c", &ch);
- for(i=0; i<strlen(str); i++)
- {
- if(str[i]==ch)
- {
- ++count;
- }
- }
- printf("\nCharacter '%c' occurs %d times", ch, count);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement