Assignment-3 (1)
Assignment-3 (1)
Program that will categorize a single character that is entered at the terminal, whether it is *
an alphabet, a digit or a special character.
11. Program that will take the final score of a student in a particular subject as input and find *
his/her grade.
13. Program that will construct a menu for performing arithmetic operations. The user will give **
two real numbers (a, b) on which the arithmetic operations will be performed and an integer
number (1 <= Choice <= 4) as a choice. Choice-1, 2, 3, 4 are for performing addition,
subtraction, multiplication, division respectively.
If Choice-4 is selected, again the program will ask for another choice (1 <= Case <=2), where
Case-1, 2 evaluate quotient and remainder respectively.
1. Addition
2. Subtraction
3. Multiplication
4. Division
1. Quotient
2. Remainder
14. Program that will construct a menu for performing arithmetic operations. The user will give ***
two real numbers (a, b) on which the arithmetic operations will be performed and an integer
number (1 <= Choice <= 4) as a choice. Choice-1, 2, 3, 4 are for performing addition,
subtraction, multiplication, division respectively.
If the check is true, the program will ask for another choice (1 <= Case <=2), where Case-1, 2
evaluate quotient and reminder respectively. If the check is false, it will print an error
message “Error: Divisor is zero” and halt.
10
Transportation Service Charge Calculator
You are tasked with developing a program for a local transportation company. The
company offers different types of transportation services, each with a different charge per
kilometer. The services and their respective charges are as follows:
1. Asks the user to choose a service by entering 1 for Car, 2 for Bus, or 3 for Bike.
2. Then, asks the user to input the number of kilometres they want to travel.
3. Calculates the total charge based on the selected service and distance.
4. Prints the total charge and service type.
Input 1 Output 1
Input 2 Output 2
10
Internet Data Package Cost Calculator
You are tasked with developing a program for an internet service provider. The company
offers different types of data packages, each with a different charge per GB. The packages
and their respective charges are as follows:
1. Ask the user to choose a package by entering 1 for Basic, 2 for Standard, or 3 for
Premium.
2. Ask the user to input the number of GBs they want to use.
3. Calculates the total cost based on the selected package and data usage.
4. Prints the total cost and the selected package type.
Input 1 Output 1
Input 2 Output 2
2. Write a C program that can calculate the area and perimeter of a rectangle. The [5]
system first takes input of a character that can be ‘A’ or ‘P’. If A is entered, the
program will compute area, and if P is entered, the program will compute
perimeter. To compute, the program needs to take two floating point numbers,
length and width first.
Formulas:
● Area of a rectangle: length * width
● Perimeter of the rectangle: 2* (length + width)
3. Take three integers as input and find the maximum value. If the maximum [5]
number is divisible by 2 print “Red Number”, or if it is divisible by 3, print “Blue
number”, or if divisible by both 2 and 3 print, “Purple number” or if it is divisible
by neither print “White number”.
34 45 40 Blue Number
10 9 7 Red Number
4. Write a C program that will take three integer numbers as input, and calculate the [5]
maximum value after using exactly one addition and exactly one multiplication
operation among those numbers. [Hints: Compute values for all three possible
combinations (a+ b*c), (b+a*c), and (c+a*b) and find the maximum value.]
1 4 7 Maximum value: 29
-5 0 3 Maximum value: 3
-3 -2 -9 Maximum value: 25
5. Write a program that will take a positive integer as input, find the last digit, and [5]
print all the digits from the last digit to digit 9. You must use switch case
statements and the last digit as its input.
54 456789
90 0123456789
9 9
16 6789
2
-0.6 0 Undefined
52 0.143
3. Take three integers as input and find the minimum among them. If the [5]
minimum number is odd, print “Red Number”, otherwise print “Blue number”.
Sample Input Sample Output
2 9 10 Valid Triangle.
1 2 3 Invalid Triangle.
5. Write a program that will take the last 4 digits of your student id and an [5]
operator as input. The program will determine the last digit of your student id
and perform an operation on that digit three times, using the switch case
statements.
1145 * 5 * 5 * 5 = 125
1123 + 3+3+3=9
1128 - 8-8–8=-8