123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Prg. to count no. of characters,no. of blanks,no. of words & no. of lines in a multi line string.

--------------------------------------------------------------------------------



#include <stdio.h>
#include <conio.h>
void main()
{
char c,choice;
int nc=0,nb=0,nw=1,nl=1,count,i/*,flag=1*/;
clrscr();
scanf("%c",&choice);

printf("ENTER STRING:- ");
printf("
String will be terminated when you press Ctrl-Z.");
printf("
STRING:- ");
while ((c=getchar())!=EOF)
{
switch(1)
{
case 1:

if (c==EOF||c==' '||c=='
')
;
else
nc=nc+1;

case 2:
if (c==' ')
{
nc=nc+1;
nb=nb+1;
while((c=getchar())==' ')
{
nb=nb+1;
nc=nc+1;
}

if (c!=' ')
{
nc=nc+1;
nw=nw+1;
}
}

case 3:
if(c=='
')
{
nc=nc+1;
nb=nb+1;
nw=nw+1;
nl=nl+1;
}
}
}
printf("

no. of characters is %d",nc);
printf("
no. of blanks is %d",nb);
printf("
no. of words is %d",nw);
printf("
no. of lines is %d",nl);

fflush(stdin);
printf ("

Do you want to continue?(y/n):- ");
scanf("%c",&choice);

getch();
}

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG