Created
July 25, 2017 19:37
-
-
Save ThePratikSah/9db858c3d385dcf35505203c3fbd3788 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(){ | |
char str[40]; | |
int i, word = 1; | |
printf("Enter a sentence:\n"); | |
scanf("%[^\n]s", str); | |
for( i = 0 ; str[i] != '\0' ; ++i){ | |
if(str[i] == ' ') | |
word++; | |
} | |
printf("Number of words = %d", word); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment