// to count the no. of characters & no. of vowels in a file
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fp;
char ch;
int nov=0,noc=0;
clrscr();
fp=fopen("b.c","r"); // here 'b' is the name of the file to be opened.
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
noc++;
if((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u'))
nov++;
}
fclose(fp);
printf("\n number of characters=%d",noc);
printf("\n number of vowels=%d",nov);
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fp;
char ch;
int nov=0,noc=0;
clrscr();
fp=fopen("b.c","r"); // here 'b' is the name of the file to be opened.
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
noc++;
if((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u'))
nov++;
}
fclose(fp);
printf("\n number of characters=%d",noc);
printf("\n number of vowels=%d",nov);
getch();
}
No comments:
Post a Comment