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
2
its digits and prints them separated by a comma each.
3
For example, if the user types in
4
42399
5
the program should print:
6
4,2,3,3,9
7
*/
8
9
#include <iostream>
10
using namespace
std;
11
12
int
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
}
main
int main()
Definition
checkpoint3.7.cpp:12
Module3
checkpoint3.7.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0