U
Umesh
Please try to do it while I try myself!
Please try to do it while I try myself!
Umesh said:Please try to do it while I try myself!
Umesh said:Please try to do it while I try myself!
Please try to do it while I try myself!
#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
{
if(ch==' ') ++num;
if(ch=='.') ++num1;
if(ch<=256) ++num2;
if(ch=='.' && c!=' ') ++num3; /* '.' followed by '.' denotes end of a
sentence.*/
}
printf("\nNo. of spaces = %ld",num);
printf("\nNo. of full stops = %ld",num1);
printf("\nNo. of characters = %ld",num2);
printf("\nNo. of characters without spaces = %ld",num2-num);
printf("\nNo. of sentences = %ld",num3);
return 0;
}
Umesh said:#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
Please try to do it while I try myself!
Please try to do it while I try myself!
Please try to do it while I try myself!
#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
Please try to do it while I try myself!
Umesh said:Please try to do it while I try myself!
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
Umesh said:#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
{
if(ch==' ') ++num;
if(ch=='.') ++num1;
if(ch<=256) ++num2;
if(ch=='.' && c!=' ') ++num3; /* '.' followed by '.' denotes end of a
sentence.*/
}
printf("\nNo. of spaces = %ld",num);
printf("\nNo. of full stops = %ld",num1);
printf("\nNo. of characters = %ld",num2);
printf("\nNo. of characters without spaces = %ld",num2-num);
printf("\nNo. of sentences = %ld",num3);
return 0;
}
Umesh said://Sorry my teachers. I've included file opening check in this program.
#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
if (f!=NULL)
{
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
{
if(ch==' ') ++num;
if(ch=='.') ++num1;
if(ch<=256) ++num2;
if(ch=='.' && c!=' ') ++num3; // '.' followed by '.' denotes end of a
sentence.
#include<stdio.h>
int main(void)
{
long int ch,c,num=0,num1=0,num2=0,num3=0;
FILE *f;
f=fopen("c:/1.txt","r");
while((ch=getc(f))!=EOF && (ch=getc(f))!=EOF)
{
if(ch==' ') ++num;
if(ch=='.') ++num1;
if(ch<=256) ++num2;
if(ch=='.' && c!=' ') ++num3; // '.' followed by '.' denotes end of a
sentence.}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.