Machine Problem 3
Machine Problem 3
BSCE 2-7
Machine Problems:
4.1. Write a code for the following display using for loops.
a. 9 b. 117 c. 1
12 104 1
15 91 2
18 78 4
21 65 7
24 52 11
27 39 16
30 26 22
33 13 29
36 0 38
4.2. Design a code for the following display using while loops.
a. 14 b. 2 c. 1
13 6 1
12 12 2
11 20 3
10 30 5
9 42 8
8 56 13
7 72 21
6 90 34
5 100 55
4.3. Create a code for the following display using do-while loops
a. 100 b. 6 c. 64
82 16 32
66 25 16
52 33 8
40 40 9
30 46 27
22 51 81
16 55 243
12 58 729
10 60 2187
4.4. Build a code for the following display using nested loops.
a. ***** b. *
**** **
*** ***
** ****
* *****
c. 54321 d. 12345
5432 1234
543 123
54 12
5 1
4.5. Using nested loops make a program that will do the following displays.
a. 1 b. 2
2 3
3 4
2 3
4 4
6 5
3 4
6 5
9 6
4.6. Create a C program that will display “I will pass PRGLF 10 times” using for loops.
4.7. Design a program using C that input 20 integers and display the sum using for
loops.
4.8. Write a code that will loop by inputting any integer and displays whether the integer
is “POSITIVE” or “NEGATIVE”, and terminate the loop if the integer is equal to zero using
while loops.
4.9. Construct a C program that will terminate the loop if the entered password is
“CORRECT”, using do-while.
4.10. Create a program that will loop by inputting any character, and terminate the loop
if “PRGLF” are entered consecutively. (Using do-while).
4.11. Build a program that will display all prime numbers from 1 to 1000 using looping.
4.12. Design a program that will input integer and display it in reverse using looping.