Write A Program for counting the number of words in a given string

#include<stdio.h> #include<conio.h> void main ( ) { char a [ 50]; int i ,s=1, l; printf (“enter a string); get...

#include<stdio.h>
#include<conio.h>
void main ( )
{
char a [ 50];
int i ,s=1, l;
printf (“enter a string);
gets ( a);
l = strlen(a);
for ( i = 0, i < l; i ++)
{
if ((a[i] = = ‘ ')  && (a[i+1] ! = ' ') || a [i]= = ‘\0’)
s++;
}
printf (“number of words %d”, s);
getch ( );
}

Related

PROGRAM FOR FINDING BIGGEST OF THREE NUMBERS

#include<stdio.h> #include<conio.h> void main() {  int a,b,c;  clrscr();  printf("\n enter a,b,c values");  scanf("%d%d%d",&a,&b,&c);  if(a&g...

PROGRAM FOR CONVERTING TEMPERATURE

#include<stdio.h> #include<conio.h> void main() {   int c;   float f;   clrscr();   printf("enter c value");   scanf("%d",&c);   f=1.8*c+32.0; ...

PROGRAM FOR CALCULATING SIMPLE INTREST

#include<stdio.h> #include<conio.h> void main() {   int p,t,r;   float si;   clrscr();   printf("enter p,t,r values");   scanf("%d%d%d",&p,&t,&am...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item