0% found this document useful (0 votes)
28 views3 pages

If-Else Practice Sheet

Uploaded by

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

If-Else Practice Sheet

Uploaded by

Keka Hazra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Branching Statements: if…else

Lab Assignments

Q# Experiment Details Input Output


1 WAP to find the largest Enter two numbers: The largest number
between two numbers. 80 is 990
990
2 WAP to read an Set 1 Set 1
alphabet from the user Enter an alphabet: k The upper case of
and convert it into Set 2 the entered letter is
uppercase if the Enter an alphabet: ‘K’
entered alphabet is M Set 2
in lowercase, otherwise You have entered ‘M’
display an appropriate which is already in
message. upper case

3 WAP to read a Set 1: Set 1:


character from the user Enter an alphabet: B The entered
and test whether it is a character B is a
vowel or consonant or Set 2: consonant
not an alphabet. Enter an alphabet: %
Set 2:
The entered
character % is not
an alphabet
4 WAP to determine Set 1: Set 1:
whether a year entered Enter the year:2005 2005 is not a leap
through the keyboard year.
is a leap year or not. Set 2:
Enter the year:1996 Set 2:
1996 is a leap year.
5 WAP to find the roots of Set 1 Set1
a quadratic equation Input values for a, b The roots are real
ax2+bx+c=0 using if- and c=>1 2 1 and equal
else statement. Roots are -1 both.

Set 2 Set2
Input values for a, b The Roots are real &
and c=>1 8 3 unequal.
Roots are -0.39 and -
7.61
Set 3 Set 3
Input values for a, b The Roots are
and c=>3 5 7 imaginary
Root1=-0.17+i1.28
Root2=-0.17-i1.28
6 WAP to display the Set-1 Set-1
grade system of KIIT Enter total mark
University based on secured by a Secured grade is C
total marks secured by student: 55
a student in a Secured grade is C Set-2
semester. Assume Secured grade is O
marks are integer Set-2
values. Use multiple if- Enter total mark
else statement. secured by a
The grade is calculated student: 95
is as follows: Secured grade is O
Marks Grade
90 to 100 O
80 to 89 E
70 to 79 A
60 to 69 B
50 to 59 C
40 to 49 D
< 40 F

7 WAP to input any two Enter 2 numbers: The Sum is 109


integers, and provide a 9
menu to the user to 100
select any of the Select the operation
options as from the menu
add, subtract, multiply, (A for Add, S for
divide and display the Subtract, M for
result accordingly Multiplication, D for
Division) :
A
8 WAP to display the Set-1 Set-1
grade system of KIIT Enter total mark Secured grade is A
University based on secured by a
total marks secured by student: 77 Set-2
a Secured grade is C Secured grade is O
student in a semester.
Use else..if ladder Set-2
statement. Enter total mark
secured by a
student: 92
Secured grade is O

9 WAP to find the roots of Input values for a, b Input values for a, b
a quadratic equation and c=> and c=>1
ax2+bx+c=0 using 1 2
switch-case statement. 2 1
1
Set2
Set2 The Roots are real &
Input values for a, b unequal.
and c=>1 8 3 Roots are -0.39 and -
7.61
Set 2
Input values for a, b Set 3
and c=>3 5 7 The Roots are
imaginary
Root1=-0.17 + i1.28
Root2=-0.17 - i1.28

You might also like