1. SUNAWAR KHAN 1
Q1: A certain grade of steel is graded according to the following conditions:
(1) Hardness must be greater than 50.
(2) Carbon contents must be less than 0.7.
(3) Tensile strength must be greater than 500.
The grades are as follows:
Grade is 10 if all three conditions are met.
Grade is 9 if conditions (i) and (ii) are met.
Grade is 8 if condition (ii) and (iii) are met.
Grade is 7 if condition (i) and (iii) are met.
Grade is 6 if only one condition is met.
Grade is 5 if none of the conditions are met.
Write a program which will require the user to give values of harness, carbon content and
tensile strength of the steel under consideration and output the grade of the steel.
Q2: Any character is entered through the keyboard; write a program to determine whether the
character entered is a capital letter, a small letter, a digit or a special symbol.
The following table shows the range of ASCII values for various characters:
Characters ASCII Values
A-Z
a-z
0-9
special symbols
65-90
97-122
48-57
0-47, 58-64, 91-96, 123-127
------------------------------------------------------------------------------------------------------------
Q3: An insurance company follows following rules to calculate premium.
(a) If a person’s health is excellent and the person is between 25 and 35 years of age and
lives in a city and is a male then the premium is Rs. 4 per thousand and his policy amount
cannot exceed Rs. 2 lakhs.
(b) If a person satisfies all the above conditions except that the sex is female then the
premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
(c) If a person’s health is poor and the person is between 25 and 35 years of age and lives in
a village and is a male then the premium is Rs. 6 per thousand and his policy cannot
exceed Rs. 10,000.
(d) In all other case the person is not ensured.
Write a program which will ask you to enter the person’s health, sex, age and policy amount.
If the policy amount do not exceed the limit then it will calculate the premium of the person
according to above given criteria otherwise says that policy amount exceeds the limit.
2. SUNAWAR KHAN 2
Note: Now here you cannot enter the complete word, like ‘Excellent’ you have to just enter
the first word of Excellent i.e. E or e whatever you like.
You can see the behavior of a program by entering the full word like ‘Excellent’, then it
will not ask you the remaining inputs because it will take the input from the remaining word
of Excellent word.
The above program works with a full word because they have only the single output while
this program takes the multiple outputs.
------------------------------------------------------------------------------------------------------------
Q4: A Company estimates salary of any job holder as
I) If basic pay is less then 1500, company provides house rent allowance @ 10%,
dearness allowance@20%, tearness allowance@50%.
II) If basic pay is greater then or equal to 1500, company provides house rent
allowance @ 50%, dearness allowance@23.3%, tearness allowance@50%,adhac
allowance@30%.
Write a program that input salary of any job holder and calculate his total salary.
------------------------------------------------------------------------------------------------------------
Q5: Write a program that input five digit numbers and find its reverse. Determine that input number
is equal to reverse number or not?
------------------------------------------------------------------------------------------------------------
Q 6: Any year entered through the keyboard. Write a program to determine whether the year is
leap year or not. Use the logical operator && and ||?
------------------------------------------------------------------------------------------------------------
Q 7: A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for
6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return book after 30 days
your membership will be cancelled.
Write a program to accept the number of days the member is late to return the book and display
the fine or the appropriate message?
------------------------------------------------------------------------------------------------------------
Q 8: Write a program that input converts ASCII number to character and vice versa. The program
should display the following menu.
1. Convert ASCII Value to Character
2. Convert Character to ASCII Value
------------------------------------------------------------------------------------------------------------
Q 9: Write a program that convert MILITARY TIME to STANDARD TIME?
------------------------------------------------------------------------------------------------------------
Q10: Write a program in which the user get working time (hours, minutes & seconds) of employee
5 times and finally determines the longest time duration of working hours.