0% found this document useful (0 votes)
8 views2 pages

Conditional Programming Exercises

Uploaded by

nusaiba.dewan57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Conditional Programming Exercises

Uploaded by

nusaiba.dewan57
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# Conditional Statement Practice Problems

## Leap Year Checker


Create a program that checks if a given year is a leap year.

## Grading System
Write a program using switch case statement that assigns a grade based on a student's score:
- If the score is greater than or equal to 90, assign "A".
- If the score is between 80 and 89, assign "B".
- If the score is between 70 and 79, assign "C".
- If the score is between 60 and 69, assign "D".
- If the score is below 60, assign "F".
Additionally, if the score is above 95, add a "+" to the grade.

## Triangle Type Checker


Write a program that takes three side lengths of a triangle and determines:
- If the sides form a valid triangle.
- If the triangle is equilateral, isosceles, or scalene.

## Time Conversion
Write a program that converts a 24-hour time format to a 12-hour format with AM/PM. For
example:
- Input: `23:15` (Hint: You may take input using `scanf("%d:%d", ...)`)
- Output: `11:15 PM`

## Quadratic Equation Solver


Write a program that solves a quadratic equation of the form `ax^2 + bx + c = 0`. Use
conditional statements to:
- Check if the equation has real roots.
- Determine if the roots are distinct or equal.
- Handle the case where `a = 0` (not a quadratic equation).

## Remaining Days of the Week


Write a program that takes a number (1-7) as input and prints the remaining days of the week. If
the number is outside this range, print "Invalid input."

## FizzBuzz
Write a program that takes a number as input and does the following:
- If the number is divisible by 3, print "Fizz".
- If the number is divisible by 5, print "Buzz".
- If the number is divisible by both 3 and 5, print "FizzBuzz".
## Second Largest Number Finder
Write a program that takes four numbers as input (the numbers may not be distinct) and
determines the second largest number among them.
- Example Input: `4, 7, 7, 2`
- Example Output: `4`

## Tax Calculator
Write a program that calculates the tax based on a person's income. Use the following tax
brackets:
- Income up to $10,000: No tax.
- Income between $10,001 and $50,000: 10% tax on the amount above $10,000.
- Income above $50,000: 20% tax on the amount
above $50,000 up to $100,000.
- Income above $100,000: 30% tax on the amount above $100,000.

### Example Calculation


- If the income is $120,000:
- No tax on the first $10,000.
- 10% tax on the next $40,000 ($10,001 to $50,000): $4,000.
- 20% tax on the next $50,000 ($50,001 to $100,000): $10,000.
- 30% tax on the remaining $20,000 ($100,001 to $120,000): $6,000.
- Total tax: $4,000 + $10,000 + $6,000 = $20,000.

You might also like