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.
...