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;
}
}
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
Post a Comment