Btech I Sem CFP A2
Btech I Sem CFP A2
Simple Programs
1. A person’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house
rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
2. The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print
this distance in meters, feet, inches and centimeters.
3. If the marks obtained by a student in five different subjects are input through the keyboard, find out the
aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be
obtained by a student in each subject is 100.
4. Program to swap of two nos using third variable.
5. Program to swap of two nos without using third variable.
6. Write a program to find out how many days and how many weeks have passed between the dates 01/01/92 to
31/05/92. Also find out how many days could not get evened out into weeks.
7. Program to find area and circumference of circle/square/rectangle.
8. Program to find the simple interest and compound interest.
9. Program to convert temperature from degree Centigrade to Fahrenheit and vice versa.
10. Find the absolute value of a number entered through the keyboard. Like if value is -12.32 abs value is 12.32
and if value is -9 abs value is 9.
If- Else
Basic HRA DA
1 - 4000 10% 50%
4001 - 8000 20% 60%
8001 - 12000 25% 70%
12000 and above 30% 80%
Note: Gross salary= Basic+ DA + HRA – 10%IT +Rs.2000 Medical Allowance.
8. Program to find loss/profit.
Dr. Mainaz Faridi Asst. Prof (CS)
BTech(‘B’) IISem (2019) CFP Lab Assignment II
While loop
1 A
22 BB
333 CCC
4444 DDDD
55555 EEEEE
19. Read a positive integer value, and compute the following sequence: If the number is even, halve it; if it's
odd, multiply by 3 and add 1. Repeat this process until the value is 1, printing out each value. Finally print out how
many of these operations you performed.
Typical output might be:
Inital value is 9
Next value is 28
Next value is 14
Next value is 7
Next value is 22
Next value is 11
Next value is 34
Next value is 17
Next value is 52
Next value is 26
Next value is 13
Next value is 40
Next value is 20
Next value is 10
Next value is 5
Next value is 16
Next value is 8
Next value is 4
Next value is 2
Final value 1, number of steps 19.
If the input value is less than 1, print an error message.