Answer to Question #332696 in C++ for Toby

Question #332696

Use a while loop to find the smallest integer n such that 3n is greater than 30000


1
Expert's answer
2022-04-23T09:04:38-0400


#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
  //Use a while loop to find the smallest integer n such that 3^n //is greater than 30000
  int n=0;
  int threePow=1;
  while(threePow<=30000)
    {
      threePow*=3;
      n++;
    }
  cout<<"The smallest n: "<<n<<endl;
  cout<<"3^"<<n<<"="<<threePow<<endl;
  cout<<"3^"<<n-1<<"="<<threePow/3<<endl;
  return 0;
}
//An easy program I don't think understand code hardly for you

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS