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

Practice Problems ConditionalStatement

Uploaded by

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

Practice Problems ConditionalStatement

Uploaded by

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

Practice Problem of Conditional Statement

1. Take any integer input through the keyboard. Write a program to find out whether it is an
odd number or an even number.
2. Take any letter input through the keyboard. Write a program to find out whether it is a
vowel or a consonant. For non-alphabet inputs, the output will be “Not an alphabet.” (Using
If-else and switch case).
3. Take a character as input through the keyboard. Write a program to find out whether the
gender is Male or Female. (Using If-else and switch case)
Inputs: take input ‘M’ or ‘m’ for male and take input ‘F’ or ‘f’ for female. For any other
input, the result will show “Undefined”.
4. Take any integer as input through the keyboard. Write a program to find out whether it is
a positive number or a negative number. (Using If-else)
5. Take Any year is input through the keyboard. Write a program to determine whether the
year is a leap year or not. Show an error message if the input number is not a year. (Using
if-else)
6. Take any 3 integer numbers. Write a program to find out the largest number among 3
numbers. (Using If-else)
7. Take any 3 integer numbers as input through the keyboard. Write a program to find out the
smallest number among 3 numbers. (Using If-else)
8. Take any 3 integer numbers are input through the keyboard. Write a program to find out
the largest number among 3 numbers and whether the largest number is Even or Odd.
(Using If-else)
9. Take any 3 integer numbers as input through the keyboard. Write a program to find out the
smallest number among 3 numbers and whether the smallest number is Even or Odd.
(Using If-else)
10. Find the absolute value of a number entered through the keyboard. (Using If-else)
11. Take any 5 integer numbers are input through the keyboard. Write a program to find out
the 3rd largest number among 5 numbers. (Using If-else)
12. Take any 5 integer numbers are input through the keyboard. Write a program to find out
the 2nd smallest number among 5 numbers. (Using If-else)
13. Take input of age of 3 people by the user and determine oldest and youngest among them.
(Using If-else)
14. A student will not be allowed to sit for an exam if his/her attendance is less than 80%.
Take the following input from the user
a. Number of classes held.
b. Number of classes that were attended by the student.
Find out the attendance percentage for the student and show if the student will be allowed
to sit for the exam or not. (Using If-else)
15. A University has the following rules for the grading system:
Mark Grade GPA
90-100 A+ 4.00
85-89.99 A 3.75
80-84.99 B+ 3.50
75-79.99 B 3.25
70-74.99 C+ 3.00
65-69.99 C 2.75
60-64.99 D+ 2.50
50-59.99 D 2.25
0-49.99 F 0.00
Write a program that will take 5 course marks as inputs. Show the received grades
for each of them. Also calculate the CGPA using the five marks.

16. If the buying price and selling price of an item is taken as user input, write a program to
determine whether the seller has made a profit or incurred a loss. Also, determine how
much profit he made or the loss he incurred. (Using If-else)

You might also like