Write a program to count number of spaces in a string.
1
Expert's answer
2012-12-07T04:08:47-0500
#include <iostream> using namespace std;
#define n 100
void main(){ char str[n]; int i; for (i=0; i<n; i++) str[i] = NULL; cout<<"Enter a string: "; gets(str); int c=0; i=0; while (str[i]!=NULL){ if ((int)str[i] == 32) c++; i++; }
cout<<"There are "<<c<<" spaces in the string.\n"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment