/*Serial No.103 [swami80.cpp]*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
int xstrlen(char *);
void main()
{
char s1[20];
int len;
clrscr();
printf("\nEnter the string:");
gets(s1);
len=xstrlen(s1);
printf("\nlength of the string =%d",len);
getch();
}
int xstrlen(char *s)
{
int l=0,m=0;
while(*s)
{
if(*s==' ')
{
m++;
}
l++;
s++;
}
printf("\nNo. of the blank spaces=%d",m);
printf("\nNo. of the words=%d",m+1);
printf("\n[--only if words are saparated by single space--]");
return (l);
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
int xstrlen(char *);
void main()
{
char s1[20];
int len;
clrscr();
printf("\nEnter the string:");
gets(s1);
len=xstrlen(s1);
printf("\nlength of the string =%d",len);
getch();
}
int xstrlen(char *s)
{
int l=0,m=0;
while(*s)
{
if(*s==' ')
{
m++;
}
l++;
s++;
}
printf("\nNo. of the blank spaces=%d",m);
printf("\nNo. of the words=%d",m+1);
printf("\n[--only if words are saparated by single space--]");
return (l);
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...