Coding Exercises

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

CODING EXERCISES: Write your name and yr. & sec in the comment.

1: Write a program that will have an output display as shown below:

Welcome (name of user)!


You can test your skill of writing C code here.

2: Write five statements to print the asterisk pattern: use increment

“Talent wins games, but teamwork and intelligence win championships. - Michael Jordan”

3: Write a program with three variables then initialize them to 10, 15, and
12.6. It then prints these values from the lowest to highest.

4: Write a program that will display the following:


18>= You may register.
If not, You may not register.

Name: (name of user)


Age: (age of user)

You may not register.

5: Write a program that will prompt the user to input 3 integer values and
print these values in forward and reversed order, sample display as shown
below:

Please enter your 3 numbers: 12 45 78

Your numbers forward:


12
45
78

Your numbers reversed:


78
45
12

6. Create a program that will add two numbers together and display the
result.

7. Ask the user to input three values of resistors (ohms) connected in parallel
and compute the total resistance of the circuit. Display the values of the
resistors and its total resistance.
8. Prompt the user to enter the username and password of her/his account. If
both details are correct, display “Welcome to ECE Department!”. If not, put
“Sorry you are not from ECE Department.”

9. Enter a number and show its even and odd number.

10.: Write program that reads two numbers and multiplies them together and
print out their product.

11: Create a program that will enter the grades of Science, Math and English.
If the grades are:
Science >= 85
Math >=87
English>=90
Display: “Congratulations, you are qualified to apply in Electronics Engineering!”
If not, display” Sorry, you may try the other programs.”

12: Write a program that performs the following: Ask a user to enter a
number. If the number is between 0 and 10, write the word blue. If the
number is between 10 and 20, write the word red. if the number is
between 20 and 30, write the word green. If it is any other number,
write that it is not a correct color option.

13: Design a program that prints all multiples of 5 between 1 and 100
(including both 1 and 100).

14: Write a program that will count all the even numbers up to a user defined
stopping point.

15: Write a program that will perform the following.


a) Read in 3 separate numbers. (Show in the display)
b) Calculate the average of the 3 numbers.

16. Input 3 numbers and print either an "all 3 are equal" or a "not all are
equal" message. Show also the entered numbers.

17.Input 3 numbers, and print the biggest

18. Input 10 numbers and print their total.

19. Read in three numbers.

 If A is bigger than B, then if A is bigger than C, print out A,


otherwise print out C.

• If B is bigger than A, then if B is bigger than C, print out B,


otherwise print out C.

20. Write five statements to print the statement: use decrement


“Education is the most powerful weapon which you use to change the world. – Nelson Mandela.”

21. Ask the user to input three values of resistors (ohms) connected in parallel
and the supply voltage in volts. Compute the total current of the circuit.
Display the values of the resistors, supply voltage and its total current.

22. Ask the user to input three values of resistors (ohms) connected in parallel
Compute the total conductance of the circuit. Display the values of the
resistors, and its total conductance.

23. Ask the user to enter her/his atm card and put her/his pin number. If both
are accepted, print “Choose your transaction: “. If one of them is not
accepted, display “Please try again.” She/He may only have three attempts to
use her/his account.

24. Design a program that will ask the user to answer questions (5 questions
only related to PLC). If the user answered the previous question correctly,
she/he may proceed to the next one. If not, print “Sorry you may not proceed
to the next number.” Last display output is the score she/he got from the test.

25. Design a program that will ask the user to answer questions (5 questions
only related to C). Last display output is/are the numbers that was answered
correctly and those that are not answered correctly.

26. Design a program that will ask the user to answer questions (5 questions
only related to Raptor). If the total score is equal to five, put” Excellent”, if
the score is equal to 4, display “Very good”, if the score is equal to 3, print
“Good”. If it is 2-0, display “Sorry, you have to repeat the subject.”

27. Prompt the user to enter her/his name and favorite color. Color and
attitude are as follows:

Red – bold
Green – calm
Yellow – happy
Other colors – have no attitude review

Sample Display:

Name: Kaori
Favorite Color: Yellow

Hello Kaori, you are a happy person.


28. Design a program that will enter the temperature and pressure. If the
temperature is 40 °C or above and the pressure more than 14.7 psi, open the
aircon. If not, turn off the aircon.

Sample display:

Temperature: 42
Air Pressure: 15
Aircon: ON

29. Develop a program that will prompt the user to enter the voltage and
current requirements of the equipment and determine the power consumption
of the equipment:

Sample Display:

Equipment: PLC
Voltage Requirement: 24 volts
Current Requirement: 0.4 A
Power Consumption: 9.6 W

30- 31. Ask the user to enter the power rating of the appliances and the
number of hours it has been used in a month (use only 3 appliances) .
Calculate the electricity consumption and the amount to be paid. Per KwH =
Php 12.00

Sample Display:

1 Television: 200 W
KwH: 22.4
1 Refrigerator: 250 W
KwH: 180
1 Electric Fan: 60 W
KwH 6.72
Total KwH: 209.12
Amount to Pay: 2509.44

You might also like