Print following series 1 3 9 27 81.....(upper limit)

#include <iostream>
using namespace std;

void main ()
{
int i=1;
int ans=1;
int upperlimit;

cout<<"Please enter the uper limit :";
cin>>upperlimit;

while (i<=2 && ans<=upperlimit) // infinite loop and a conditional loop
{
cout<<ans<<"\t";
ans=ans*3;

}
}

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System