Friday, 11 July 2014

Input 3-Digit Number and Output Each Digit on Separate Line

Problem

The problem is to input a 3 digits number from the user. And then break that number into digits and show each digit on separate line. This problem should be solved using C++ (C Plus Plus) programming language.
Note: The problem was sent to me by my friend "Ali Aftab".



Solution

Here is the C++ program that accurately solves above given problem.
#include <iostream>
#include <conio>

void main(){
	clrscr();
   int num,rmd,quo;
   cout<<"Enter a Number = ";
   cin>>num;
   quo=num/100;
   rmd=num%100;
   cout<<quo<<endl;
   quo=rmd/10;
   cout<<quo<<endl;
   rmd=rmd%10;
   cout<<rmd;
   getch();
}

No comments:

Post a Comment