Answer to Question #16323 in C++ for Tahreem virk

Question #16323
Write a program that inputs a five-digit integer, separates the integer
into its digits and prints them separated by three spaces each. For example, if the user types in 42339, the program
should print:
4 2 3 3 9
1
Expert's answer
2012-10-16T09:45:55-0400
#include<iostream>
using namespace std;

int i, a, b, c, d, e;

void main(){
cout<<"enter a five-digit integer: ";
cin>>i;
e = i%10;
d = ((i-e)/10)%10;
c = (((i-e)/10-d)/10)%10;
b = ((((i-e)/10-d)/10-c)/10)%10;
a = (((((i-e)/10-d)/10-c)/10-b)/10)%10;
cout<<a<<" quot;<<b<<" quot;<<c<<" quot;<<d<<" quot;<<e<<"\n";
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS