Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Strings

Home > Programs > Strings

9 / 59

Write a program to count the no. of words in the given string?

Answer:

#include 
#include 
int main()
{
  char str[50];
  int count=0,i;
  printf("enter any string : ");
  scanf("%[^\n]s",str);
  for(i=0;str[i]!='\0';i  )
  {
    if(str[i]==' ')
       count  ;
  }
  printf("reverse string is : %d\n",count 1);
  
}

Asked In :: Virtusa

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: