#include <iostream> using std::cin; using std::cout; using std::endl; int main() { int fivedigit; int first, second, third, fourth, fifth; cout << "Please enter the five digit integer: "; cin >> fivedigit; if(fivedigit < 10000) { cout << "Incorrect digit! Try again!"; } if(fivedigit > 99999) { cout << "Incorrect digit! Try again!"; } first = fivedigit/10000; second = (fivedigit/1000)%10; third = (fivedigit/100)%10; fourth = (fivedigit/10)%10; fifth = fivedigit%10; cout << first; cout << " " << second; cout << " " << third; cout << " " << fourth; cout << " " << fifth; return 0; }
Tuesday, October 27, 2015
Write a program that inputs a five-digit integer, separates the integer into its digits and prints them separated by three spaces each.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment