0% found this document useful (0 votes)
6 views

Lab Assignment240924

jjj

Uploaded by

zoyan2705
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab Assignment240924

jjj

Uploaded by

zoyan2705
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Fall Session 2024-25

Course Name & Code: Computer Programming (CSE104)


Program & Sem: B.Tech 1st Sem
Section: D

Lab Assignment (Decision Control)


1. Write a C program that calculates the absolute difference between an input number
and 50, if the input number is greater than 20, double the absolute difference.

Sample Input 1: 15
Sample Output 1: 35

Sample Input 2: 60
Sample Output 2: 20

2. Write a C program that verifies an input number is divisible by 3 or 7 and falls between
100 and 500. If the condition is satisfied the program should print 1 otherwise it should
print 0

Sample Input 1: 42
Sample Output 1: 0

Sample Input 2: 350


Sample Output 2: 1

3. Write a C program that takes three numbers as input. If all numbers are distinct,
output the difference between the second highest and lowest. If all three numbers are
equal, output the sum of all. If any two numbers are equal, print the sum of the lowest
and highest

Sample Input 1: 10, 15, 20


Sample Output 1: 5

Sample Input 2: 10, 10, 10


Sample Output 2: 30

Sample Input 3: 10, 10, 20


Sample Output 3: 30

4. A gym offers a special discount on membership renewal based on attendance. To qualify


for the discount, a member must meet the following criteria:

• Attend at least 80% of their scheduled sessions.


• Have no outstanding payments or dues.
• Have been a member for at least 6 months.
Write a C program that takes the following inputs from a gym member: Scheduled
Sessions, Attended Sessions, Any Outstanding Payments (1 for Yes 0 for No), No. of months
as a member

The program should then display the following message if the member is eligible for
discount:

Congratulations! You qualify for the special discount on membership renewal.

OR if the member is not eligible for discount, then the program should display the
following message

Print Sorry, you do not qualify for the special discount on membership renewal.
(Reason for not qualifying should also be printed)

Sample Input:

enter the scheduled_sessions:8


enter the attended_sessions:4
enter 1 for outstanding payment and 0 for no dues: 1
enter the months as a member:5

Sample Output:

Sorry, you do not qualify for the special discount on membership renewal.
(Attendance < 80%)

5. Write a C program to calculate the electricity bill (accept number of units from the
user) according to the following criteria:

• First 50 units Rs. 0.0 per unit and service charge Rs. 0.30 per unit.
• Next 50 units Rs. 1.50 per unit and service charge Rs. 0.40 per unit.
• Next 100 units Rs. 2.50 per unit and service charge Rs. 0.50 per unit.
• After 200 units Rs. 3.75 per unit and service charge Rs. 0.60 per unit.

For example, if input is 350 then the total bill amount is

(50*0.0+50*0.30)+(50*1.50+50*0.40)+(100*2.50+100*0.50)+(150*3.75+150*0.60)=1062.5

6. A fitness app rewards users with badges based on their workout performance. The
badges are awarded according to the following rules:

If a user completes at least 5 workouts in a week, they receive the "Week Warrior" badge.

If a user burns more than 500 calories in a single workout, they receive the "Calorie
Crusher" badge.
If a user logs a workout every day for a month (at least 28 workouts), they receive the
"Monthly Streak" badge.

If a user achieves both the "Week Warrior" and "Calorie Crusher" badges, they receive
the "Fitness Champion" badge.

Write a C program that takes the number of workouts completed in a week, the calories
burned in a workout, and whether the user has logged a workout every day for a month
as inputs. The program should then determine which badges the user has earned and
display the results accordingly.

Sample Input:

Enter the workouts per week:9


Enter the calories burned:30
Enter the workouts per month:8

Sample Output:

Print Congratulations! You've earned the Week Warrior badge.

You might also like