1.Study the following code and write down what you think gets printed. Then write a test program to check your answers.
int a, b=0, c=0;
a = ++b + ++c;
printf("%d %d %d\n",a, b, c);
a= b++ + c++;
printf("%d %d %d\n",a, b, c);
a= b-- + --c;
printf("%d %d %d\n",a,b,c);
2. Assume that there are 4 variables as follows:
int a=1, b=2, c=3, d=4;
What is the final value of the following expressions:
a * b/c
a * b%c + 1
++a * b - c--
7- -b* ++d
3. Conditional Control Structures
1. The marks obtained by a student in 5 different subjects are input through the keyboard. The student gets a division as per the following rules:
Percentage above or equal to 60 - First Division
Percentage between 50 and 59 - Second Division
Percentage between 40 and 49 - Third Division
Percentage less than 40 - Fail
Write a program to calculate the division obtained by the student.
2. A company insures its drivers in the following cases:
- If the driver is married
- If the driver is unmarried, male & above 30 years of age
- If the driver is unmarried, female & above 25 years of age
In all other cases, the driver is not insured. If the marital statusm gender and age of the driver are the inputs, write a program to determine whether the driver should be insured or not.
3. A year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||.
4. If a character is entered through the keyboard, write a program to determine whether the character is a capital letter, a small case letter, a digit or a special symbol.
ASCII TABLE
==================================
Characters ASCII Values
A-Z 65-90
a-z 97-122
0-9 48-57
special 0-47, 58-64,
symbols 91-96,123-127
5. If the lengths of three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides.