Computer Science, asked by js6189764, 22 days ago

WAP to read the content of file and count how many vowels in it.​

Answers

Answered by aniket1234549
1

Explanation:

In this program integer type variables declare (vowel,Consonant) and pointer of file (FILE *fp1;). And control statements also used if the given situation is not true then the arguments will be insufficient else it will go on. Nested if statements also come into use the next move is to if the file pointer is null then the source will not open. While condition tells the (ch!EOF) not equal to End of File. If condition used with the OR (!!) operator. This Will checks out the given characters match the condition. Then it’s Vowel else consonant. And in the last move, it will be counted as a result.

Problem Statement:-

Here in the program user has to count the Vowel with the use of the file handling Concept.

Checks out The Given Arguments.

Using the Control Statements.

Applying Required Statements.

Display Result on Screen.

The C program is successfully compiled. The program output is also shown below.

#include<process.h>

#include <stdio.h>

        void main(int argc,char *argv[])

 {

         

          FILE *fp1;

          int vowel=0,consonant=0;

          char ch;

          clrscr();

          if(argc!=2)

            {

                     printf("Insufficient Arguments");

                     exit(0);

            }

          fp1=fopen(argv[1],"r");

          if(fp1==NULL)

            {

                    printf("Source can't be opened");

                    exit(0);

            }

          ch=fgetc(fp1);

          while(ch!=EOF)

                {

                       if((ch=='a')||(ch=='A')||(ch=='e')||(ch=='E')||(ch=='i')||(ch=='I')||(ch=='o') ||(ch=='O')||(ch=='u')||(ch=='U'))

                         {

                               vowel++;

                          }

                      else

                         {

                             consonant++;

                         }

                             ch=fgetc(fp1);

                }

                             printf("\n Number of vowels are = %d",vowel);

                             getch();

}

Answered by dineshjdj58
1

Answer:

comment aachu pannunga summa kathitu iruka mari iruku.!.!.!.!..!!.

Similar questions