Question
C++ Code Without chaning any code below, could anyone help me to get the second line? Ex1) Please enter a number from 3 to 100:
C++ Code
Without chaning any code below, could anyone help me to get the second line?
Ex1)
Please enter a number from 3 to 100: 6
2, 4 (<--------This is what I need - there should be no comma at the end!)
The answer is 4
Please enter a number from 3 to 100: 100
2, 4, 8, 16, 32, 64 (<-------this is what I need - no comma at the end!)
The answer is 64
#include
int powerOfTwo(int num);
int main () { int num; int result; int i=1; cout<<"Please enter a number from 3 to 100: "; cin>>num; cout << num << endl; if ((num < 3) || (num > 100)) cout << "Please follow the directions!" << endl; else { int pow; pow = powerOfTwo(num); cout << " The answer is "; cout << pow; cout << endl; } } int powerOfTwo(int num) { int N = num; int v = 1;
while (v <= N/2) v *= 2;
cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started