Ask Question
18 July, 05:24

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. 18 July, 08:28
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers