I need a head-up on this program....i really don't know where to start....however for section one, i'm guessing we'll have to use for loop from 1000 to 9999...because of the fact that they show the range of the samllest to largest 4 digit #'s. In section two I guess we'd have to set some value from the lowest 2 digit # to the largest 4 digit #. I'll try to start a code and post as soon as I can. The assignment is as follows:
There are two sections to this program.
Section one:
Write a C++ program that determines which four digit numbers meet the following conditions:
Add the first two digits as a number to the last two digits as a number. The square of this sum equals the original number.
Example:
Original number is 4321. Determine if 43 + 21 which equals 63, when squared, is 3969 is equal to the original number (4321).
Section two:
The program continues by determining which 2, 3, and 4 digit numbers are equal to the sum of the cubes of their digits.
Example:
If the original number is 234, determine if 2 cubed (8) + 3 cubed (27) + 4 cubed (64) which is 99 is equal to the original 234.
Thanks for all the help.
zandiago
115
Nearly a Posting Maven
Featured Poster
Recommended Answers
Jump to PostOK. Well for section one you should look into the division and remainder operators and loop ... Could be a long loop so think about it and see if there are any tricks you can use.
Section 2 is very similar.
Look at this code:
Jump to Posthere is a thought:: make one function that returns the last two digits of the number, and another one that returns the first two... Then in a loop add these parts , square them and check if they are equal to the loop counter..
One note:: are you sure …
Jump to Post// ... for( int i = 1 ; i < 10 ; ++i ) for( int j = 0 ; j < 10 ; ++j ) for( int k = 0 ; k < 10 ; ++k ) for( int m = 0 ; m < 10 …
Jump to PostCause
if ((temp * temp) == j)returns false?
All 15 Replies
twomers
408
Posting Virtuoso
n.aggel
13
Posting Whiz in Training
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured Poster
vijayan121
1,152
Posting Virtuoso
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured Poster
twomers
408
Posting Virtuoso
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured Poster
n.aggel
13
Posting Whiz in Training
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured Poster
zandiago
115
Nearly a Posting Maven
Featured 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.