Answer:
This program is implemented in C++ using dev C++. The solution of this answer along with running code is given below in explanation section.
Step-by-step explanation:
#include <iostream>
#include<string>
using namespace std;
int main()
{
string str;
cout<<"Enter String \\";
getline(cin,str);/* getLine() function get the complete lines, however, if you are getting string without this function, you may lose date after space*/
//cin>>str;
int count = 0;// count the number of characeter
for (int i = 1; i <= str.size(); i++)//go through one by one character
{
if ((str[i]!=32)&&(str[i]!=44)&&(str[i]!=46))//do not count period, comma or space
{
++ count;//count the number of character
}
}
cout << "Number of characters are = "; //display
cout << count;// total number of character in string.
return 0;
}
}