Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ with comments (Exercise 1) Write a program to decide whether an integer valu

ID: 3759113 • Letter: C

Question

C++ with comments

(Exercise 1)

Write a program to decide whether an integer value is power of 2 or not. Your function should return true if the value is power of 2, otherwise return false.

(Exercise 2)

The factorial function ( symbol: !) means to multiply a series of descending nature number. Write a program to calculate the factorial of the number entered by the user.

For example:

4! = 4 × 3 × 2 × 1;

0! = 1

(Exercise 3)

Write a fucntion that takes as a parameter an integer (as a long value) and returns the number of odd, even and zero digits. Also write a function to test your function.

Explanation / Answer

Exercise 1:

Exercise 2:

#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

// Variable Declaration

int counter, n, fact = 1;

// Get Input Value

cout<<"Enter the Number :";

cin>>n;

//for Loop Block

for (int counter = 1; counter <= n; counter++)

{

fact = fact * counter;

}

cout<<n<<" Factorial Value Is "<<fact;

// Wait For Output Screen

getch();

return 0;

}

Exercise 3:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote