Answer to Question #154821 in C++ for zeeshan wahab

Question #154821

a) Use the knowledge of C++ programming to develop a program that takes marks of

05 subjects, compute the average marks and display on the screen? Also paste

the screen shots of the output.


b ) Following is the program to check whether a number is palindrome or not. Execute this

in the softww are, input any number and manually show the step by step change in variable

“digit”, “rev” and “num” in a table for all iteration being done in the do-while loop. Also

paste the screen shots of the output?

#include <iostream>

using namespace std;

int main()

{

int n, num, digit, rev = 0;

cout << "Enter a positive number: ";

cin >> num;

n = num;

do

{

digit = num % 10;

rev = (rev * 10) + digit;

num = num / 10;

} while (num != 0);

cout << " Thee reverse of the number is: " << rev << endl;

if (n == rev)

cout << " Thee number is a palindrome.";

else

cout << " Thee number is not a palindrome.";

return 0;

}

value/variable digit rev num

initial value

2nd changed value

3rd changed value


c ) Use if-else structure to develop a program to check whether the entered year is

leap year or not. Also paste the screen shots of the output (Hint: Leap years occur

every 4 years, but every 100 years we skip a leap year unless the year is divisible

by 400).


d) Following is the program to find largest number using if statement, execute this in

the software and determine the errors (if any)? Correct these errors and paste the

screen shots of the output in the solution?

#include <iostream>

using namespace std;

int main()

{

float n1, n2, n3;

cout << " Enter three numbers " ;

cin >> n1 , n2 , n3;

if(n1 >= n2 || n1 >= n3)

{

cout << "Largest number: " << n1;

}

if(n2 >= n1 || n2 >= n3)

{

cout << "Largest number: " << n2;

}

if(n3 >= n1 || n3 >= n2) {

cout << "Largest number: " << n3;

}

return 0;

}


e )Use the knowledge of C++ programming to implement a program to count total number

of notes in given amount. Also paste the screen shots of the output

e.g. Input amount: 575, Output: 500: 1, 100: 0, 50: 1, 20: 1, 10: 0, 5: 1, 2: 0, 1


f) Using for-loop, develop a program to print all odd number between 1 to 100. Also

paste the screen shots of the output


g)

Following is the program to finn d factorial of a given number, execute this in the softww are

and determine the errors (if any)? Correct these errors and paste the screen shots of the

output in the solution?

#include <iostream>

using namespace std;

int main()

{

unsigned int n;

unsigned long long factorial = 1;

cout << "Enter a positive integer: ";

cin >> n;

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

{

factorial *= i;

}

cout << "Factorial of " << n << " = " << factorial;

return 0;

}


h) Implement &amp; execute a program to Swap any two numbers using temporary

variable. Also paste the screen shot of the output.



1
Expert's answer
2021-01-11T00:11:10-0500
Dear zeeshan wahab, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

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