Ask Question
22 January, 22:28

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

+3
Answers (1)
  1. 22 January, 22:54
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers