How do I accept multiple numbers

closed account (9G3v5Di1)
Write a program that will accept a short value from 10 to 99 and display them per digit (separated by a space).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include "_pause.h"

using namespace std;

int main(){
	int num;

	cout << "Enter a number from 10 to 99: ";
	cin >> num;

	if(num > 9 && num < 100){
		cout << num;
	}

	cout << endl;
	
	std::cin.get();
	_pause();
	return EXIT_SUCCESS;
}


How do I accept multiple numbers?
1
2
3
4
5
if( num > 9 && num < 100 ) { // if it is a positive two digit number

    std::cout << num/10 /* first digit eg. 78/10 == 7 */ << ' ' /* space */ 
              << num%10 /* second digit eg. 78%10 == 8 */ << '\n' /* new line */ ;
}
closed account (9G3v5Di1)
wow thank you
closed account (9G3v5Di1)
what if I use two functions to do this.. is it possible? Because the problem came from the topic of 'Functions Procedures'
It is possible. Try to do it.
closed account (9G3v5Di1)
I've done it. Thank you!
Topic archived. No new replies allowed.