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

Write A Program to Check the given number is Palindrome or not

#include<stdio.h> #include<conio.h> main ( ) { int x, y, n , pal=0; printf (“enter x value “); scanf (“% d”, & x) ; n=x; while ( x > 0) {  y = x%10; pal = pal * 10...

Program for Finding Factorial of a given number using Recursion

#include<stdio.h> #include<conio.h> fact ( int n); main( ) { int n, r; printf (“enter a value “); scanf (“/d”,&n); r=fact(n); printf (“factorial is % d “,r); } fact ( int...

Program for Transpose of a given Matrix.

#include<stdio.h> #include<conio.h> main ( ) { int a[10][10],b[10][10],m,n,i,j; printf (“enter number of rows and columns”); scanf (“%d%d”, & m, &n); printf (“enter elemen...

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