[Solved] Ask the user for a number between 3 and 100 (CPP)

$25

File Name: Ask_the_user_for_a_number_between_3_and_100_(CPP).zip
File Size: 461.58 KB

SKU: [Solved] Ask the user for a number between 3 and 100 (CPP) Category: Tag:
5/5 - (1 vote)

Ask the user for a number between 3 and 100 (inclusive). USING LOOPS, figure out what is the largest power of 2 that is less than or equal to the number entered. For example, if the user entered 6, answer would be 4. If the user entered 100, the answer would be 64. You must do this within a function called powerOfTwo. For example:

Please enter a number from 3 to 100: 100The answer is 64

Please only edit code where is says /* Type your code here. */

#include#includeusing namespace std;

/* Type your code here. */

int main(){int num;cout cin num;cout if ((num 100))cout else {int answer = powerOfTwo(num);cout }}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Ask the user for a number between 3 and 100 (CPP)
$25