Aptitude test assistant programmer 2018

 #include <stdio.h>

#include <stdlib.h>

int main()

{

char str[100];

int i;

int space=0;

    printf("Enter a string\n");

    fgets(str,sizeof(str),stdin);

    i=0;

    while(i<=str[i]){

 if(str[i]==' '){

        space++;

    }

    i++;

}

printf("Total word count :%d" ,space+1);

 

    return 0;

}

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

1041A. Heist solution