Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Input a number and distinctly display its digit. Each digit must be printed on a separate line.

0 votes
asked Feb 18, 2018 by anonymous
by bhavya gala

1 Answer

0 votes
answered Feb 19, 2018 by Aniket Jangam
Try this...

#include <iostream>

using namespace std;

int main()
{

    int a;
    cout<<"Enter a number: "<<flush;
    cin>>a;
    
    
    while (a!=0){
        int b = a % 10;
        a = a/10;
        cout<<b<<endl;
    }
    
    return 0;
}

// written by Aniket Jangam
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...