Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help needs to be running on Linux. Want the same input / output provided in the question. Thank you! greetings.txt hello how are you

Need help needs to be running on Linux. Want the same input / output provided in the question. Thank you!

image text in transcribed

image text in transcribed

greetings.txt

hello how are you i am good

countChar2.c

#include // define EOF

main(){

int c;

int count = 0;

c = getchar();

while(c != EOF) /* no end of file*/

{

count++; //include spaces and ' '

c = getchar(); /* read next */

}

printf("# of chars: %d ",count);

}

7. Problem F2 getchar, character comparison (15 pts) Specification The provided program uses getchar() to read input character by character, counting the number of characters from the standard input (keyboard or redirected from an input file). Modify the program so that it also counts the number of characters 'a' in the input. Implementation Name your program countchar2.c Hint: you might need to compare every character getchar reads in against the character 'a'. In Java or C, how to compare two characters? Sample Inputs/Outputs red 307 % gcc countChar2.c -o cc2 red 308 % cc2 hello how are you? I am good and Thanks! AD # of chars: 41 # of char 'a': 4 red 309 % cc2 hello how are you I am good AD # of chars: 28 # of char 'a': 2 red 310 % cc2

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions