1.

Write a program to read a string and print the number of spaces.

Answer»

# include<iostream>

# include<cstdio>

using namespace std;

int main()

{

char str[40];

int space=0,i;

cout<<” Enter a string:”; 

gets(str);

for(i=0;str[i]!='\0'/;i++)

if(str[i]==32)

space++;

cout<<"The number of space is"<<space;

}



Discussion

No Comment Found