You are on page 1of 1

Q W.A.

P TO FIND THE NUMBER OF SPACES IN A


STRING#include<iostream.h>#include<conio.h>#include<stdio.h>#include<string.h>void
main(){ clrscr(); char a[40]; cout<<"ENTER A STRING"; gets(a); int count=0;for(int
i=0;a[i]!='\0';i++) { if(a[i]==' ') count++; } cout<<"THE NUMBER OF SPACES ARE: ";
cout<<"\t"<< count;}OUTPUTENTER A STRING this has four spacesTHE NUMBER OF SPACES
ARE: 4

You might also like