I want to my program to prompt user to input a number with three or more integers I need the program to output a space between each numebr
example: cin>>3334;
i want the output to show 3 3 3 4 each with a space and then i also need to output the sum of these number so 3+3+3+4? how do i do this can some help me asap
thanks a lot in advanced
stefy14
0
Newbie Poster
Recommended Answers
Jump to Postint _tmain(int argc, _TCHAR* argv[]) { int i = 0; int number; int resto[10]; int sum = 0; cout << "input number\n"; cin >> number; while (number > 0) { resto[i] = number%10; sum = sum + resto[i]; number = number/10; i++; } for (i = i-1; …
Jump to PostThere is actually a very simple solution to this problem. First, you are trying to do two things here:
1. Split an input number into separate digits. 2. Add the digits together.
First of all, I would not recommend putting your input into an int type. If …
Jump to Post>>I want to my program to prompt user to input a number with three or more integers
You know how to get the user input into a variable right ?
int var1 = 0 , var2 = 0, var3 = 0; cin >> var1 >> …
All 11 Replies
gabryprof
2
Newbie Poster
dusktreader
137
Posting Whiz in Training
mrnutty
761
Senior Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
mrnutty
761
Senior Poster
Fbody
682
Posting Maven
Featured Poster
stefy14
0
Newbie Poster
oselenius
0
Newbie Poster
vijayan121
1,152
Posting Virtuoso
oselenius
0
Newbie Poster
amisha_1
0
Newbie Poster
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.