i need answer for this Q is that how we can write program in C++ to eccept any number and print it with its digit? and thanx^^

Recommended Answers

All 7 Replies

cin and cout would be a fair start.

commented: !!!how? +0

You'll need to better define the problem.

Do you mean to take in words that define a number, like "two thousand forty five" and convert to digits, 2045?
Or to take in a numeric value, like 2045 and display as separate digits, 2 0 4 5?

Once you have the problem figured out, write some code to solve it. If you have problems, post your code here and ask questions.

I mean like
int x;
cin>>x;
cout<<x<<the digit;
i need the code that except the number and print it and next its digit

I have a test tomorrow and I want to answer it on one of my question please

I have a test tomorrow and I want to answer it on one of my question please

What is your definition of a digit? A number is a digit or is made of digits so I'm not sure what you are talking about.

x % 10 will return the right most digit, for example if x = 15 then x%10 will return 5. Now put that in a loop, divide x by 10, to get all the digits

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.