write a program using nested loop to produce 0 2 2 4 4 8 8
Answers
Answered by
0
Answer:
gghugklhssgikzusdkyllufpjfjpdjdldp
Answered by
0
Answer:
#include<bits/stdc++.h>
using namespace std;
int main()
{
for(int i=0; i<=3; ++i)
{
for(int j=0; j<2; ++j)
{
if(i==0)
cout<<"0";
else
cout<<pow(2,i);
}
}
return 0;
}
Explanation:
Series is increasing exponentially as 0, 2¹, 2², 2³.....
First for loop will take care of increasing power and second for loop will handle the number of prints you want, in this case it's printing twice every time.
Similar questions