0% found this document useful (0 votes)
100 views

Btech I Sem CFP A2

This document contains a list of programming assignments for students, including simple programs to calculate gross salary, convert between distance units, and find student percentages. It also lists programs using if/else statements to check number properties, solve quadratic equations, and calculate salaries with varying pay scales. While loops are provided for problems like displaying numbers and their sums, reversing numbers, and checking number properties. The document ends with a problem to iteratively calculate values until reaching 1.

Uploaded by

hdgdyfj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Btech I Sem CFP A2

This document contains a list of programming assignments for students, including simple programs to calculate gross salary, convert between distance units, and find student percentages. It also lists programs using if/else statements to check number properties, solve quadratic equations, and calculate salaries with varying pay scales. While loops are provided for problems like displaying numbers and their sums, reversing numbers, and checking number properties. The document ends with a problem to iteratively calculate values until reaching 1.

Uploaded by

hdgdyfj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

BTech(‘B’) IISem (2019) CFP Lab Assignment II

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

1. Program to check Whether a Number is Even or Odd in the given range.


2. Program to check Whether a Character is Vowel/consonant/digit/upper case/lowercase/special character.
Characters Ascii values
Upper Case 65-90
Lower Case 97-122
Digits 48-57
3. Program to find the Largest Number among Three Numbers Entered by User.
4. Program to find all Roots of a Quadratic equation. The expression underneath the
square root sign is called the discriminant of the quadratic equation (delta).

If the discriminant is positive, then there are two distinct roots.

If the discriminant is zero, then there is exactly one real root

If the discriminant is negative, then there are no real roots.

5. Program to check whether the Entered Year is Leap Year or not


6. Program to check whether a Number is Positive or Negative or Zero.
7. Accept the salary of an employee from the user. Calculate the gross salary on the following basis:

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

9. Program to show the use of conditional operator.


10. Program to convert days to years, months and weeks.
11. Program to student grade acc to the following scheme:
Grade Percentage
A >90
B 81-90
C 71-80
D 61-70
F Fail.
12. Program to calculate taxi fare acc to the following rates:
KM Rs/Km
0-100 5
101-250 6
251-400 7
Night stay Rs.1000/Night

13. Program to shift a number by two bits to the left.


14. Program to show use of increment and decrement operators (++, --).
15. Write a C program to input angles of a triangle and check whether triangle is valid or not.
16. Write a C program to input all sides of a triangle and check whether triangle is valid or not.
17. Write a C program to input all sides of a triangle and check whether triangle is Equilateral, Isosceles or Scalene
triangle.
18. In an inter-college competition, various sports and games are played between different colleges like cricket,
basketball, football, hockey, lawn tennis, table tennis, carom and chess. The information regarding the games
won by a particular college is stored in bit numbers 0, 1, 2, 3, 4, 5, 6, 7 respectively of an integer variable called
game. The college that wins in 5 or more than 5 games is awarded the Champion of Champions trophy. If a
number is entered through the keyboard, then write a program to find out whether the college won the
Champion of the Champions trophy or not.
19. The information about colors is to be stored in bits of a char variable called color. The bit number 0 to 6, each
represent 7 colors of a rainbow, i.e. bit 0 represents violet, 1 represents indigo, and so on as given below.
Write a program that asks the user to enter a number and based on this number it reports which color in the
rainbow does the number represents.
Red Orange Yellow Green Blue Indigo Violet
20. Write a program that displays water bills. Your program should prompt the user to enter an integer account
number, a character use code, and a real number representing the gallons of water used. The output from
your program should include the account number, message indicating the type of usage, and the amount of
money due from the user. Draw a flowchart for your program.
The water rates vary depending on the type of usage. A code of H means home use, a code of C means commercial
use, and a code of I means industrial use. Any other code value should be treated as an error. Water rates are
computed as follows:
Code H: Rs 1000.00 plus Rs 5.50 per gallon
Code C: Rs5000.00 for the first 4 million gallons used plus
Rs 10.0 for each additional gallon used
Code I: Rs10000.00 if usage does not exceed 4 million gallons
Rs20000.00 if usage is between 4 million and 10 million gallons
Rs25000.00 if 10 million gallons or more

Dr. Mainaz Faridi Asst. Prof (CS)


BTech(‘B’) IISem (2019) CFP Lab Assignment II

While loop

1. Program to display first 10 natural no & their sum.


2. Program to count number of digits of anumber.
3. Program to Reverse a Number.
4. Program to Calculate the Power of a Number.
5. Program to Check Whether a Number is Palindrome or Not.
6. Program to Check Whether a Number is Prime or Not.
7. Program to Display Prime Numbers between Two Intervals.
8. Program to Check Armstrong Number.
9. Program to Display Armstrong Number between Two Intervals.
10. Program to find sum of digits of a number.
11. Program to Display Factors of a Number
12. Program to multiply twonos without using *.
13. Program to divide twonos without using /.
14. If a five-digit number is input through the keyboard, write a program to print a new number by adding one
to each of its digits. For example if the number that is input is 12391 then the output should be displayed
as 23402.
15. Program to Generate Multiplication Table of a given number.
16. Program to Print All ASCII Values.
17. Program to display series 2,4,16,256...
18. Use a nested while loop to reproduce the following output

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

Dr. Mainaz Faridi Asst. Prof (CS)


BTech(‘B’) IISem (2019) CFP Lab Assignment II

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.

20. Program to calculate n even numbers using ‘continue’.


21. Write a program to enter the numbers till the user wants and at the end it should display the count of
positive, negative and zeros entered.

Dr. Mainaz Faridi Asst. Prof (CS)

You might also like