Answer to Question #291306 in C++ for ali

Question #291306

 Create a program that uses a do-while loop to count the number of characters (not including whitespace) entered by the user. The count should end when it first encounters a # character in the input.


1
Expert's answer
2022-01-27T10:47:19-0500
#include <iostream>
#include <string>
#include <math.h>


using namespace std;






int main()
{
	string text;
	cout<<"Enter string: ";
	getline(cin,text);
	int count=0;
	int i=0;
	do{
		if(text[i]!=' ' && text[i]!='#'){
			count++;
		}
		i++;
	}while(text[i]!='#');
	cout<<"The number of characters: "<<count<<"\n";


	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog