SQL

Wednesday, 21 May 2014

Separate integers, i.e 67890 will output 6 7 8 9 0

#include <iostream>
#include <iomanip>
using namespace std;

int quotient(int, int);
int reminder(int , int);
int main(){

int number;
int divisor = 10000;

cout << "ENter an integer between 1 - 32767 :";
cin >> number;

cout << "THe Digit in the number are :\n";

while (number >= 1){

if (number >= divisor){

cout << setw(3)<<quotient(number, divisor);
number = reminder(number, divisor);
divisor = quotient(divisor, 10);
}
else
divisor = quotient(divisor, 10);

}
cout << endl;
return 0;

}
int quotient(int a, int b){

return a / b;
}
int reminder(int a, int b){

return a % b;
}

Post a Comment