AedenCak3

C program to count number of SPACES in string

Dec 8th, 2021
977
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     char a[100];
  6.     int space=0, i;
  7.  
  8.     printf("Write a sentence: \n");
  9.     gets(a);
  10.  
  11.     for(i=0; a[i]!='\0'; i++)
  12.     {
  13.         if( a[i]==' ' )
  14.         {
  15.             space+=1;
  16.         }
  17.     }
  18.  
  19.  
  20.     printf("The number of  spaces in the sentence are : %d",space);
  21.  
  22.  
  23.     return 0;
  24. }
  25.  
RAW Paste Data