Write a program (C++) that reads a number between 1,000 and999,999 from the user where the user enters a comma in the input.Then print the number without a comma. EXAMPLE:Here is a sample dialog, the user input is in italics.

Respuesta :

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

ACCESS MORE