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"); }
Comments
Leave a comment