/* 7.write a program to enter text with gets() and display
it using printf() statement also find the lenth */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a=0,k=0;
char str[97];
clrscr();
printf("enter a text:");
gets(str);
printf("\n\nyour entered text is: %s",str);
for(i=0; str[i] !='\0'; i++)
{
if(str[i] !=' ')
{
a++;
}
}
printf("\n\nyour entered text lenth is: %d",a);
getch();
}
/* output:
enter a text:vrushal pandav
your entered text is: vrushal pandav
your entered text lenth is: 13
*/
No comments:
Post a Comment