Ask Question
27 October, 07:55

Write a for loop that prints the values 1 2 4 8 16 32 64 by increasing the value of a counting variable by a factor of two in each cycle.

+2
Answers (1)
  1. 27 October, 09:02
    0
    Following code is in C++.

    #include

    using namespace std;

    int main () {

    int count=1;

    for (int i=1; i<=6; i++)

    {

    count*=2; / /multiplying the count variable.

    cout<
    }

    return 0;

    }

    Output:-

    2 4 8 16 32 64

    Explanation:

    I have initialized a variable count with the value 1 after that I have ran a loop from 1 to 6 and in each iteration in the loop the count variable is multiplied by 2. After that just printing the output.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a for loop that prints the values 1 2 4 8 16 32 64 by increasing the value of a counting variable by a factor of two in each cycle. ...” 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