help in a very simple program

I want to write a program that asks the user to enter an integer on 3 digits, extract and display each digit.
#include <iostream>

using namespace std;
void main()
{
char hundreds;
char tens;
char ones;

cout<<"Please enter your 3 digit number"<<endl;
cin>>hundreds>>tens>>ones;
static_cast<int>(hundreds);
static_cast<int>(tens);
static_cast<int>(ones);

cout<<"The last number you entered is: "<<endl;
cout<<hundreds%10<<endl;
//to display the last number and then i continued in a smilar way, however im getting incorrect results.When I'm entering 345,im getting 3 instead of 5 for the last number! please help!
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main()
{
char hundreds;
char tens;
char ones;

cout<<"Please enter your 3 digit number"<<endl;
cin>>hundreds>>tens>>ones;
static_cast<int>(hundreds);
static_cast<int>(tens);
static_cast<int>(ones);

cout<<"The last number you entered is: "<<endl;
cout<<ones<<endl;

}


something like this?
Topic archived. No new replies allowed.