0
Can anyone correct this for me?
#include <iostream> #include <string> using namespace std; int main() //take user input //use long to accomodate 999 billion long n; cout << "Enter the number:"; cin >> n; //preparing output string s; while{ if (n >1000){ //no need for commas s = to_string(n) + s; break; } else { //get the remainder with 1000 s = "," + to_string(n%1000) + s; n /= 1000; } } cout << "number with commas:" << s << endl; }
7 ответов
+ 5
U missed curly brac after main function put curly brac then try to run your code . Its a very small mistake first try to solve errors by self. If u unable to solve then post here.
Hope u understood thanks.
+ 1
Where is the condition for your while loop....
While(Boolean expression){
Statement...
}
0
You are missing a '{' after main()
0
It's still not running
0
Could you post the code here?
0
#include <iostream>
#include <string>
using namespace std;
int main()
//take user input
//use long to accomodate 999 billion
long n;
cout << "Enter the number:";
cin >> n;
//preparing output
string s;
while{
if (n >1000){
//no need for commas
s = to_string(n) + s;
break;
} else {
//get the remainder with 1000
s = "," + to_string(n%1000) + s;
n /= 1000;
}
}
cout << "number with commas:" << s << endl;
}
0
Thanks