Ask 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.

+3
Answers (1)
  1. 4 December, 17:35
    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?
Find 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 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