B.Tech. 1 Year 2 Semester Lab Assignment 2: Decision Control Programs

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

B.Tech.

1st Year 2nd Semester

LAB ASSIGNMENT 2

Decision Control Programs


Write a C Program
1. Write a C program to find the maximum of three numbers using conditional operator.
2. Write a C program to find the absolute value of a number using conditional operator. (e.g. if
input is +25, then output is 25; if input is 25, then output is 25; if input is −25, then output is
25).
3. To find out whether any integer, input through the keyboard, is odd or even
4. To determine whether a given year, input through the keyboard, is leap year or not.
5. To find the maximum of 3 numbers.
6. To find the absolute value of a number.
7. To check whether a given alphabet is vowel or not.
8. To check whether a number input from keyboard is positive or negative or zero.
9. To determine whether a character input from keyboard is a capital letter, a small case letter, a
digit or a special symbol.
10. Write a C Program to find the roots of a quadratic equation
ax2 + bx + c = 0
for all possible combination of a, b and c.
[A quadratic equation will have two roots which are obtained using the following
expression:
x = −b ± (sqrt of (b2 −4ac))/2a
Note: when b2 −4ac > 0 the roots are real and unequal
b2 −4ac = 0 the roots are real and equal i.e. x = −b/2a
b2 −4ac < 0 the roots are imaginary]

Characters ASCII Values


A-Z 65-90
a-z 97-122
0-9 48-57
Special symbols 0-47, 58-64, 91-96, 123-127
*****

You might also like