COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
checkpoint3.7.cpp
Go to the documentation of this file.
1/* Write a program that inputs a five-digit integer, separates the integer into
2its digits and prints them separated by a comma each.
3For example, if the user types in
442399
5the program should print:
64,2,3,3,9
7*/
8
9#include <iostream>
10using namespace std;
11
12int main(){
13 int x, y=10000;
14 cin >> x;
15 for (int i=5; i>0; i--){
16 cout << x / y;
17 if (i>1){
18 cout << ",";
19 }
20 x %= y;
21 y /= 10;
22 }
23
24 return 0;
25}
int main()