Hello,
I got an question:
If user enters 1-10 range of natural number ( only positive numbers ).
I have to find sqrt of natural numbers that is in the range of 1-10.
For example out put should be:
1sqrt+1sqrt = 2
1sqrt+2sqrt = 4
1sqrt+3sqrt = 10
2sqrt + 2sqrt = 8
Is there a way i can check all sqrts if they are in range of 1-10 for example?
If range is 5-15... then output should be
1+9 = 10
Well im stuck with that...
I need to sum all the number squares of for example:
1 + 1 = 2
1 + 2 = 5
1 + 3 = 10
1 + 4 =17
2 + 2 = 8
and so on...
And when user enter a range of 1-10 for example...
I need to print out the numbers that makes sum that is in the users range if that makes sence.
On paper it looks like you have what will translate into two loops in code.
The outer loop is the left square and the inner loop is the right square.
12 + 12 = 2 print to screen and increment right square
12 + 22 = 5 print to screen and increment right square
12 + 32 = 10 print to screen and increment right square
12 + 42 = 17 17 is > 10, so increment left square and right square = 1
22 + 12 = 5 print to screen and increment right square
22 + 22 = 8 print to screen and increment right square
22 + 32 = 13 13 is > 10, so increment left square and right square = 1
32 + 12 = 10 print to screen and increment right square
32 + 22 = 13 13 is > 10, so increment left square and right square = 1
42 + 12 = 17 The program would stop here
Notice how the right square is increasing by one each time and the condition on stopping is that the summation is greater than the upper bound of the range the user specified. And each time the right square resets to one (the inner loop stops and gives control back to the outer loop), the left square is incremented by one. The outer loop's condition on stopping seems to be when adding 12 to the left square produces a number bigger than the upper bound given by the user.
sqrt - Stands for square root, so I was a bit confused by your first post. And then the second time I realized you were squaring not square rooting. http://www.cplusplus.com/reference/cmath/sqrt/
It is also possible to use superscripts by clicking the A2 button in the format section to the right of the text edit area.