TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Count the Number of Occurrences of Any Character from Input String
Rupesh Kahane
Dec 23
2015
Code
853
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
characher_occureance
#include<stdio.h>
#include<conio.h>
main()
{
char
string[150], Mychar;
int
count=0, j=0;
printf(
"Please enter a string:\n"
);
gets(string);
printf(
"Please enter the character for find occurances of that: \t"
);
scanf(
"%c"
, &Mychar);
while
(string[j]!=
'\0'
)
{
if
(string[j]==Mychar)
count++;
j++;
}
printf(
"Above string contains %c occurred %d times \n"
,Mychar, count);
getch();
}
count the number of occurrenes of any single character
Input String