Sheet 5
Sheet 5
Q1-
Suppose the input is 2 3 4 5 0. What is the output of the following code?
Q2-
Convert the following while loop into a do-while loop.
Q3-
Convert the following while loop into a for loop.
Q4-
Write a C++ program that prompts the user to input an integer. Use a loop to print
the multiplication table for that number up to 10.
Sheet 5
Q5-
Write a C++ program that prompts the user to input an integer. Use a loop to print
the multiplication table for that number up to 10.
Q6-
Write a C++ program that takes a positive integer and calculates its factorial using
a loop.
Q7-
Write a C++ program that prompts the user to enter an integer and uses a loop to
count the digits in the integer.
Q8-
Write a C++ program that calculates the sum of all digits in a given integer.
Q9-
Write a C++ program that takes 10 integers from the user and determines the
maximum and minimum numbers in the list.
Q10-
Write a C++ program that calculates the sum of all even and odd numbers from 1
to n, where n is entered by the user.
Q11-
Write a C++ program that calculates the sum of the following series and displays
the result.
the series:
1 − 1/2 + 1/3 − 1/4 + . . .until a term is reached that is less than 0.0001.