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

Assignment selection statement(RLKU)

The document contains a list of practical programming assignments focused on selection statements in C, including if, if-else, if-else-if, and switch. Each assignment requires writing a program to perform specific tasks such as checking odd/even numbers, determining grades, and validating inputs. The tasks range from basic to more complex programming challenges, covering various concepts in C programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment selection statement(RLKU)

The document contains a list of practical programming assignments focused on selection statements in C, including if, if-else, if-else-if, and switch. Each assignment requires writing a program to perform specific tasks such as checking odd/even numbers, determining grades, and validating inputs. The tasks range from basic to more complex programming challenges, covering various concepts in C programming.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

C Programming: Practical Assignments on Selection

Statements (if, if-else, if-else-if, switch)"


1. Write a program that takes an integer input and checks whether the number is odd or even
using an if-else statement.
2. Write a program that checks whether a number is positive, negative, or zero using if-else-if
statements.
3. Write a program that takes the marks of a student (out of 100) and prints the grade based on
the following conditions:
o 90–100: A+
o 80–89: A
o 70–79: B
o 60–69: C
o 50–59: D
o Below 50: Fail Use if-else-if statements.
4. Write a program to check if a year is a leap year or not. A year is a leap year if:
o It is divisible by 4 but not divisible by 100, or
o It is divisible by 400. Use if-else statements.
5. Write a program that takes a character input and checks if it is a vowel (a, e, i, o, u) or a
consonant using an if-else statement.
6. Write a program that takes three numbers as input and prints the largest number using if-else-if
statements.
7. Write a program that takes a number between 1 and 7 and prints the corresponding day of the
week (1 = Sunday, 2 = Monday, ..., 7 = Saturday) using a switch statement.
8. Write a program that takes two numbers and an operator (+, -, *, /), then performs the
corresponding operation. Use a switch statement.
9. Write a program that checks if a number is divisible by both 3 and 5. If divisible by 3, print
"Divisible by 3". If divisible by 5, print "Divisible by 5". If divisible by both, print "Divisible by 3
and 5".
10. Write a program that takes n numbers as input and calculates the sum of even and odd numbers
separately using if-else statements.
11. Write a program that takes an integer n and inputs n numbers, then prints the largest number
using if-else-if statements.
12. Write a program that takes a character as input and checks if it is uppercase, lowercase, or a
non-alphabet character using if-else statements.
13. Write a program that takes three numbers and finds the smallest number using if-else-if
statements.
14. Write a program that takes a character input and checks whether it is an alphabet, a digit, or a
special character using if-else-if statements.
15. Write a program that takes a numeric grade (1-5) and prints the corresponding letter grade (1 =
A, 2 = B, 3 = C, 4 = D, 5 = F) using a switch statement.
16. Write a program that displays a menu for addition, subtraction, multiplication, and division and
performs the operation selected by the user using a switch statement.
17. Write a program that checks if a number is prime or not using if-else statements.
18. Write a program that takes a number between 1 and 9 and prints the number in words (e.g., 1 =
"One", 2 = "Two", etc.) using a switch statement.
19. Write a program that takes three numbers and prints the second largest using if-else-if
statements.
20. Write a program that takes the three sides of a triangle and checks whether they form a valid
triangle using the conditions:
 The sum of any two sides must be greater than the third side. Use if-else
statements.
21. Write a program that calculates the average of n numbers using if-else statements to check for
valid inputs.
22. Write a program that checks whether a given year is divisible by 4 using an if-else statement.
23. Write a program that takes four numbers as input and prints the largest using if-else-if
statements.
24. Write a program that checks if the input character is a digit (0-9) or not using an if-else
statement.
25. Write a program that takes a number as input and prints the sum of its digits using a while loop
and if-else statements.
26. Write a program that checks if a given number is a palindrome (reads the same forwards and
backwards) using if-else statements.
27. Write a program that takes five numbers as input and prints the largest using if-else-if
statements.
28. Write a program to check whether a number is a perfect number (equal to the sum of its
divisors) using if-else statements.
29. Write a program that calculates the factorial of a number using an if-else statement to check if
the number is negative.
30. Write a program that checks if a character is a special symbol (e.g., @, #, $, etc.) using an if-else
statement.
31. Write a program to find the sum of prime numbers between two given numbers using if-else
statements.
32. Write a program that calculates the sum of even numbers between two given numbers using if-
else statements.
33. Write a program that checks if a given number is an Armstrong number (sum of its digits raised
to the power of the number of digits) using if-else statements.
34. Write a program that prints the Fibonacci series up to the nth term using if-else statements for
validation.
35. Write a program to check whether a given year is a leap year using a switch statement.
36. Write a program to check whether a number is even or odd using a switch statement.
37. Write a program that prints all even numbers up to a given number n using an if statement to
check divisibility.
38. Write a program that calculates the power of a number (base^exponent) using if-else
statements for non-negative integers.
39. Write a program that converts a character to uppercase or lowercase based on the input using
if-else statements.
40. Write a program that checks if a number is positive or negative using a switch statement.
41. Write a program that takes four numbers as input and finds the smallest number using if-else-if
statements.
42. Write a program that counts the number of digits in a number using a while loop and if-else
statements.
43. Write a program that calculates the average of even numbers between two given numbers using
if-else statements.
44. Write a program that checks if the input character is a letter or a digit using if-else-if statements.
45. Write a program that takes a month (1–12) as input and prints the number of days in that
month using a switch statement.
46. Write a program that checks whether a given number is divisible by both 7 and 11 using if-else
statements.
47. Write a program that checks if a number is an Armstrong number using if-else statements.
48. Write a program to check if a year is divisible by 400 using if-else statements.
49. Write a program that converts a temperature from Celsius to Fahrenheit using the formula F = C
* 9/5 + 32 and if-else for valid input checks.
50. Write a program that counts the number of even and odd digits in a given number using if-else
statements.

You might also like