#include<stdio.h>
#include<conio.h>
void main()
{
char a[50];
int i,j,n,totword=1,totchar=0,totline=1;
clrscr();
printf("\n Please Give The Value of N: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
flushall();
printf("\n enter value of a[%d] :",i);
scanf("%c",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]==32 || a[i]=='.' || a[i]=='\0')
{
totword++;
totchar++;
}
elseif(a[i]=='\n')
{
totline++;
totword++;
}
else
totchar++;
}
printf("\n\nTHE TOTAL STRING IS \n\n");
for(i=0;i<n;i++)
printf("%c",a[i]);
printf("\nTHE TOTAL NO. OF CHARACTERS %d .",totchar);
printf("\nTHE TOTAL NO. OF WORDS %d .",totword);
printf("\nTHE TOTAL NO. OF LINES %d .",totline);
getch();
}
********************** OUTPUT ***********************************************
Please Give The Value of N: 6
enter value of a[0] :A
enter value of a[1] :S
enter value of a[2] :D
enter value of a[3] :
enter value of a[4] :D
enter value of a[5] :F
THE TOTAL STRING IS
ASD DF
THE TOTAL NO. OF CHARACTERS 6 .
THE TOTAL NO. OF WORDS 2 .
THE TOTAL NO. OF LINES 1 .
*********************************************************************************