Answer / Explanation:
#include <iostream>
using namespace std;
int main()
{
int userNum = 0;
userNum = 20;
cout << userNum << " ";
while (userNum > 1)
{
userNum = userNum/2;
cout << userNum << " ";
}
cout << endl;
return 0;
}
However, we should note that the above codes divides properly but when it gets to 0, it will always give output as 0 instead of terminating the program.
Hence to make it terminate, we include:
while (userNum > 1)
{
cout << userNum << " ";
userNum = userNum/2;
}
The above code alternatively should be replaced with int userNum = 0; .
Also, for the sake of industry best standard and the general principle, we can say:
The general principle is:
while ( <conditional> )
{
// Use the data
// Change the data as the last operation in the loop.
}
A for loop provides natural placeholders for these.
for ( <initialize data>; <conditional>; <update data for next iteration> )
{
// Use the data
}
If you were to switch to using a for loop, which I recommend, your code would be:
for ( userNum = 20; userNum > 0; userNum /= 2 )
{
cout << userNum << " ";
Answer:
i dont know you can find the expl below
Explanation:
In this unit, you learned that a test generator can be very helpful when trying to determine if a code runs properly or fails in some situations. For example, let’s say that you were writing a program where the user would input their test grades and the program would tell them their average. What kinds of data would a test generator want to test for that program to be sure that it would work in all situations?
You should always cite your sources with a referral to the person.
Well can't do it for you but try using that phrase argument with string compare functionality
Answer:
1.82
Explanation:
i'm not sure if 182 was supposed to be a fraction or a percent? i answered from converting a percent into a decimal (182%=1.82)