Write only the loop statements to print the following sequence .
1) 1 2 4 8 16
2) 1 2 4 6 10 15
3) 243 81 27 9
4) 111 222 333 444 555
5) 16 11 7 4 2 1
6) 1 1 2 3 5 8 13 21
#include <iostream>
using namespace std;
int main()
{
 // 1 2 4 8 16
 for(int i=1;i<=16;i=i*2){
   cout<<i<<" ";
 }
cout<<"\n";
// 1 2 4 6 10 15
for(int i=1;i<=15;i=i+i){
   cout<<i<<" ";
 }
  return 0;
}
Comments
Leave a comment