Write a program that reads input as a stream of characters u

Write a program that reads input as a stream of characters until encountering EOF. Have the program report the number of uppercase characters, the number of lowercase characters, and the number of other characters read. (You can use the functions in ctype.h for this assignment.) Use the attached file infile.txt as input when you submit your assignment.

Solution

#include<stdio.h>

#include<process.h>

void main() {

   FILE *a1; //Pointer for reading file.

   char a;

int upper = 0, lower= 0;

   clrscr();

a1 = fopen(\"inline.txt\", \"r\"); //Opening file in read mode

   if (a1 == NULL) {

      puts(\"cannot open this file\");

      exit(1);

   }

while(!a1.eof())  

do {

      a = fgetc(a1);

      if(a>=’a’ && a<=’z’)

            lower++;

     else if(a>=’A’ && a<=’Z’)

            upper++;

   }

fcloseall();

   getch();

}

Write a program that reads input as a stream of characters until encountering EOF. Have the program report the number of uppercase characters, the number of low

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site