Professional Documents
Culture Documents
Write a program that prints the message “Hello World “ twenty (20) times on the screen. Use a looping
structure.
Question 2:
Write a program that asks the user to enter 5 integers one by one through keyboard. The program then
displays the product of all those five integers. Use a looping structure.
Question 3:
Write a program that first asks the user to enter the number of positive integers, N, to be entered. The user
then enters those N integers one by one. The program then displays the sum of all positive integers
entered. If the user enters a negative number, that number should not be added to the sum.
Question 4:
Write a program that computes the double number Z using the following series up to 100 terms. Use a
looping structure. All divisions are real, floating-point divisions.
Z = 1 + (1/2) + (1/3) + (1/4) + …. + (1/100)
Question 5:
Write a program that first get the value of a positive integer N (where N > 0) from the user. It then
computes the double number Z using the following series. Use a looping structure. All divisions are real,
floating-point divisions.
Z = 1 + (1/2) + (1/3) + (1/4) + …. + (1/N)
Z = 2.92897
Question 6:
Write a program that prints the table of fractions of type (1/N) where N=1,2,.., 100, and their
corresponding double values. The sample output should look like:
1/1 1.0
1/2 0.5
1/3 0.33
.. ..
1/100 0.01
Question 7:
Write a program that read a double number x (where x < 1) from the user and computes the double
number Z using the following formula: Use a looping structure.
Z = 1 + x + x2 +x3 +….+ x10
Note: The pow (x, n) in <cmath> library gives the result for xn .
Z = 1.6666
Question 8:
Write a program that prints all integer numbers between 1 and 100 that are completely divisible by 9.
A number N is completely divisible by 9 if the division of N by 9 gives zero remainder.
Question 9:
Write a program that prints all numbers between 1 and 100 that are divisible by both 5 and 7.
Question 10:
Write a program that inputs a positive integer N from the user. It then computes and prints the sum of all
positive even integers between 1 to N (both limits included). Use a looping structure.
Question 11:
Write a program that is going to allow the users to type in letters, until 'q' or ‘Q’ is pressed. When the user
enters 'q' or ‘Q’, the program displays how many lowercase vowels the user typed in.
Hint: Think of do-while !!
The lowercase vowels are the following characters: ’a’, ‘e’, ‘i’, ‘o’, ‘u’.
Question 12:
Write a program that gets 5 characters through keyboard one by one from the suer. The program then
counts how many times the user entered character ‘A’ or ‘a’, and then prints this count. Use a looping
and if structure(s).
Question 13:
Write a program that gets 5 characters through keyboard one by one from the suer. The program then
counts how many times the user entered character ‘A’ or ‘a’, and then prints this count. Use a looping
and a switch-case structure.