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

Subject: PRF192- PFC

Workshop 01
Contents: 5 programs

Program 1 2 3 4 5
Mark 2 2 2 2 2

Program 1 ( 2 marks)

Write a program that allows the user to input 4 parameters, including 3 characters
and an integer n.
Given:
int n;
char varC1, varC2, varC3;
Your program will display n lines that look like the following
Test case 1 Test case 2

Note that: Your StudentID and your name (just name) must be in the display content.

Program 2 ( 2 marks)
Develop a program in C to calculate the electricity cost for Vietnamese residential
use with the following requirements:
The electricity cost is calculated cumulatively in tiers according to the following levels:
• Tier 1: For kWh from 0 – 50: Price: 1.403 vnd/kWh.
• Tier 2: For kWh from 51 – 100: Price: 1.459 vnd/kWh.
• Tier 3: For kWh from 101 – 200: Price: 1.590 vnd/kWh.
• Tier 4: For kWh from 201 – 300: Price: 1.971 vnd/kWh.
• Tier 5: For kWh from 301 – 400: Price: 2.231 vnd/kWh.
• Tier 6: For kWh from 401 and above is 2.323 vnd/kWh.
Input: The input to the program is the number of kWh of electricity consumed by
individuals
Given:
int so_kW;

huyvv10@fpt.edu.vn 1
Output: Includes 3 parameters: Total electricity cost consumed; VAT (10%); Total amount
to be paid. (3 results must be in a single line and a single space between them) as below:

Case 1 Case 2
Input: 45 Input: 45
Output: 63135 6313.50 69448.50 Output: 89117 8911.70 98028.70

Case 3 Case 4
Input: 164 Input: 417
Output: 250194 25019.40 275213.41 Output: 548850 54885.00 603735.00

Program 3 (2 mark)
Develop a program in C. Your system will accept 2 integer numbers (num1 and num2,
num1<num2; num1>=2) and display the list of factorials from num1 to num2:
Given:
int num1, num2;
Case 1 Case 2
Input: 5 20 Input: 24
Output: 5 7 11 13 17 19 Output: 29

Program 4 (2 mark)
Develop a program in C. Your system will accept an integer (int month;) representing
the months of the year. If month between 1 and 12, the system will display the word form of
that month and the number of days in that month. For February, it will display 28 or 29 days.
In case the input number is not a month (out of the range 1 and 12), the system will display
“Not a month of the year.”
Given:
int month;

huyvv10@fpt.edu.vn 2
Case 1 Case 2

Input: 2 Input: 8
Output: February has 28 or 29 days Output: August has 31 days

Case 3 Case 4

Input: 15 Input: 11
Output: Not a month of the year Output: November has 30 days

Program 5: (2 marks)
Develop a program in C. Your system will accept an input character from the
keyboard. The system will display whether it is a lowercase character, uppercase character,
a number, or a special character as the figure below.
Given:
char character;

Case 1 Case 2

Input: b Input: F
Output: b is a lowercase character. Output: F is a capital charater.

Case 3 Case 4

Input: 8 Input: $

huyvv10@fpt.edu.vn 3
Output: 8 is a number. Output: $ is a special character.

END

huyvv10@fpt.edu.vn 4

You might also like