Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Language Programming: Question: Devise a program that counts the number of characters in its input up to the end of file. I enclose the

C Language Programming:

Question: "Devise a program that counts the number of characters in its input up to the end of file."

I enclose the Main driver and my program for count_ch.

"Main driver"

image text in transcribed

Here is my prgram for count_ch

image text in transcribed

My problem is that if I run my program without the "main driver" my program runs correctly. I don't know what's wrong with it. Please have a look at it on count_ch program and correct if there is any mistake. Thanks for your help!

#include #include //header file for input/output int menu(void) //prototype definition /*Place the function prototypes for your programs here! / void count_ch(void); void chartype (void); void betterguess (void); int main(void) int selectionmenu(); /Ivariable declaration and initialization via call to menu //The line above also serves as the priming" read for the following while loop while (selection ! 99) //The switch statement is similar to a chained if-else except conditions fall through in C! switch(selection) case 1: count ch); break; case 2: chartype) break; case 3: betterguess); break; case 4: break; default: /* Optional-but a good idea expecially if you have no other error catching! */ printf("Please enter a valid selection. "); selection = menu(); // get the next menu selection, otherwise, you have an eternal loop! return 0; int menu(void) int choice; printf("%n"); printf("1. Character count In") printf(" 2. Character type n") printf(" 3. Better Guess ") printf" 4. In") printf("99. Exit "); printf("Please select number and press enter: ") printf("n"); scanf ("%d", &choice); return choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions