4.16 LAB: Count characters Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. You may assume that the string does not contain spaces and will always contain less than 50 characters. Ex: If the input is: n Monday the output is: 1 n Ex: If the input is: z TodayisMonday the output is: 0 z's Ex: If the input is: n It's sunnytoday the output is: 2 n's Case matters. Ex: If the input is: n Nobody the output is: 0 n's n is different than N. 1 #include 2 #include 3 4 int main(void) { 5 6 7 8 9} 10 /* Type your code here. */ return 0; main.c Load default template...

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
4.16 LAB: Count characters
Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the
string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not
exactly 1. You may assume that the string does not contain spaces and will always contain less than 50 characters.
Ex: If the input is:
n Monday.
the output is:
1 n
Ex: If the input is:
z TodayisMonday
the output is:
0z's
Ex: If the input is:
n It's sunnytoday
the output is:
2 n's
Case matters.
Ex: If the input is:
n Nobody
the output is:
0 n's
n is different than N.
1 #include <stdio.h>
2 #include <string.h>
3
int main(void) {
5
6
7
8
9}
10
/* Type your code here. */
return 0;
main.c
Load default template...
Transcribed Image Text:4.16 LAB: Count characters Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. You may assume that the string does not contain spaces and will always contain less than 50 characters. Ex: If the input is: n Monday. the output is: 1 n Ex: If the input is: z TodayisMonday the output is: 0z's Ex: If the input is: n It's sunnytoday the output is: 2 n's Case matters. Ex: If the input is: n Nobody the output is: 0 n's n is different than N. 1 #include <stdio.h> 2 #include <string.h> 3 int main(void) { 5 6 7 8 9} 10 /* Type your code here. */ return 0; main.c Load default template...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Guessing the output
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning