Chapter 6:
Looping Structures
Programming Exercise
Problem # 23:
Write a program to print the following sequence:
1 3 9 27 81 ... 200
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int c;
for(c=1;c<=200;c*=3)
{
cout<<c<<"\t";
}
getch();
}
#include<conio.h>
using namespace std;
int main()
{
int c;
for(c=1;c<=200;c*=3)
{
cout<<c<<"\t";
}
getch();
}
Let me know in the comment section if you have any question.
Previous Post:
https://csprogrammingtutorial.blogspot.com/2018/05/22-program-to-print-following-sequence.html
Comments
Post a Comment