Ask Question
4 July, 04:50

Write a while loop that prints that number doubled without reaching 100. Follow each number with a space. After the loop, print a newline. Ex: If num Insects = 8, print: 8 16 32 64

+5
Answers (1)
  1. 4 July, 08:06
    0
    The program to this question as follows:

    Program:

    #include / /defining header file

    using namespace std;

    int main () / /defining main method

    {

    int n; / /defining integer variables

    cout<<"Enter number: "; / /message

    cin>>n; / /input value by user

    while (n< 100) / /loop for check condition

    {

    cout<
    n=n*2; / /calculate value

    }

    return 0;

    }

    Output:

    Enter number: 8

    8 16 32 64

    Explanation:

    In the above C+ + language code, a header file is included, then defining the main method, inside the method an integer variable n is defined, which is used for user input for calculating their double number.

    In the next step, The while loop is declared, and the loop variable n range is defined, that its value is less than 100, inside the loop the variable n is used to calculate, its double number, and print function "cout" to print its value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a while loop that prints that number doubled without reaching 100. Follow each number with a space. After the loop, print a newline. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers