Pages

Monday, October 7, 2013

Enter 3-digit code in c++

This will be the output:
Enter 3-digit: 123
First Digit: 1
Second Digit: 2
Last Digit: 3
The reverse value: 321

This is the code

# include <iostream>
using namespace std;
int main ()
{
int a=0, b=0, c=0, d=0;
cout<<"Enter 3-digit:"; cin>>d;
a=d/100;
b=(d-(a*100))/10;
c=d-((a*100)+(b*10));
cout<<endl;
cout<<"First Digit:"; cout<<a;
cout<<"Second Digit:"; cout<<b;
cout<<"Last Digit:"; cout<<c;
cout<<"The Reverse Value:"; cout<<c&&cout<<b&&cout<<a;
cout<<endl;
system ("pause");
}


No comments:

Post a Comment