C++ program to print the digit without a comma
#include<iostream>
#include<string>
using namespace std;
void commaremoval(string num) /*Defining function commaremoval with parameter num of string type*/
{
string s=num;
for(int i=0; i< s.length();i++)
{
if(s[i]!=',') /*Checking whether the string doesn't contain ' ,' */
cout<<s[i]; //Printing Output without comma
}
}
//driver function
int main()
{
string num;
cout<<"Enter a digit between 1,000 and 999,999:"<<endl; /*taking input from user*/
cin>>num;
commaremoval(num); //calling function
return 0;
}
Output
Enter a digit between 1,000 and 999,999: 22,343
22343