Skip to Main Content
Programming and Data Structures
book

Programming and Data Structures

by Ashok Kamthane
August 2009
Intermediate to advanced content levelIntermediate to advanced
604 pages
21h 39m
English
Pearson India
Content preview from Programming and Data Structures
Arrays 203
char f;
clrscrO;
puts ("Enter a String:");
gets (s);
puts("Enter a Character to Find
f=getchar();
for (i=0,H<=15,n++)
I
if(s[i]~f)
C + + ;
I
printf ("The Character (%c) in a String (%s) occurs %d times ”,f,s,c);
I
PITIFUL
Enter a String: programmer
Enter a Character to Find: r
The Character (r) in a String (programmer) occurs (3) times.
Explanation In this program the string and a single character is entered through the keyboard.
Inside the for loop, i f statement checks each element of the string for occurrence of the single entered
character. If the character ( ' r ') is found then c counter is increased otherwise without increasin ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Data Structures and Algorithms

Learning Data Structures and Algorithms

Rod Stephens
Data Structures and Algorithms in C++, Second Edition

Data Structures and Algorithms in C++, Second Edition

Michael T. Goodrich, Roberto Tamassia, David M. Mount

Publisher Resources

ISBN: 9789332506343