Hello I need help in fixing part b anc c. the problem with part b is that the out put is the higher integer versus what the actual input was. for example i put in integer 1 and 5 but get 5 and 5 is: 3..
The problem I have with part c is that it is not doing the exponents instead it does something else not sure what i did wrong since i did follow some online guides for doing exponents.
DIRECTIONS FOR PART B:
1 2 3 4 5 6 7
(b) Next, you will prompt the user for a pair of integers and output the length of the
interval between the numbers. Example: if the input is \5 5" the length is 0, if
the input is \1 9" the length is 7.
This time you will use a while loop to determine the interval.
There are no incorrect values here, any two integers will do.
When the computation is done, output the length like
The interval between 1 and 5 is: 3
//// PART B:
cout << "Please input two integers: " << endl;
cin >> integer1;
int interval(int integer1, int integer2);
int counter = 0;
if(integer2 < integer1)
while (++integer1 < integer2)
int intervalAmount = counter;
cout << "The interval between " << integer1 << " and " << integer2 << " is: " << intervalAmount << endl ;
DIRECTIONS FOR PART C
1 2 3 4 5 6 7 8 9 10 11
Last you will compute the product n^i. Prompt the user for two integers and make
Now you will use a do-while loop.
The rst value input, n can be any integer. The second value, i, must be
non-negative. If the i input is negative, you will continue to prompt the user
for a new pair of values, n and i, where the i is non-negative. Note: If the
input values are large, the result will \over
ow" and what is printed out will
really be garbage. That is the way things happen sometimes.
When the computation is done, output the product like
The product of 3 ^ 4 is: 81
/// PART C:
int pow (int base, int exponent);
int result = 1, i = 0;
cout << "Please input two integers, the second must be non-negative: " ;
cin >> base;
cin >> exponent;
result *= base;
cout << "The product of " << base << " ^ " << exponent << " is " << result << endl;
while (i++ < exponent);