You are on page 1of 4

Lab No.

2
Practical No. 7
Task: Write a program that accepts two integer numbers as input
from the user and display their sum using three variables num1 for
first number, num2 for second number and sum for their sum.
Practical No. 8
Task: Write a program that accepts two integer numbers as input
from the user and display their sum using two variables num1 for
first number and num2 for second number.
Practical No. 9
Task: Write a program that accepts two floating point (having
decimal) numbers as input from the user and display their sum,
difference, product, and quotient (division) using six variables
num1 for first number, num2 for second number, sum for storing
their sum, diff for storing their difference, prod for storing their
product and div for storing their quotient (result of division).
Practical No. 10
Task: Write a program that accepts temperature in Fahrenheit as
input from user and display temperature in Centigrade on the
screen using formula C = 5/9(F-32) (Conversion formula).
Practical No. 11
Task: Write a program that accepts temperature in Centigrade as
input from user and display temperature in Fahrenheit on the
screen using formula F = 9C/5+32 (Conversion formula).
Practical No. 12
Task: Write a program that accepts Initial Velocity (vi) ,
Acceleration (a) and Time (t) as input from user and display Final
Velocity (vf) on the screen using formula vf = vi + at (First Equation
of motion).
Practical No. 13
Task: Write a program that accepts Initial Velocity (vi) ,
Acceleration (a) and Time (t) as input from user and display
Distance Covered (s) on the screen using formula s = vit + ½ at 2
(Second Equation of motion).
Practical No. 14
Task: Write a program that accepts Initial Velocity (vi) ,
Acceleration (a) and Distance Covered (s) by object , as input from
the user and display acceleration (a) on the screen using formula a
= (vf2 – vi2)/2s (Third Equation of motion).
Practical No. 15
Task: Write a program that accepts radius of a circle as input from
the user and calculates the diameter, circumference and area of
the circle and display the result, using formulae
D = 2r
A = п r2
C=2пr
Where r = Radius of circle, D=Diameter of circle, A=area of circle
and
C = circumference.
Practical No. 16
Task: Write a program that accepts distance covered by Train in
km as input from the user and calculates the distance in meter,
feet, inches, and centimeter using formulae
meter = km * 1000,
centimeter = meter * 100,
inch = cm / 2.54,
feet = inch / 12.
Practical No. 17
Task: Write a program that accepts Ahmed’s basis salary as input
from the user, his dearness allowance is 40% of basic salary and
house rent allowance is 20% of basic salary, calculate his gross
salary.
Practical No. 18
Task: In a town, the percentage of men is 52. The percentage of
total literacy is 48. If total percentage of literate men is 35 of the
total population, write a program to find the total number of
illiterate men and women if the population of the town is 80,000.
Practical No. 19
Task: Write a program that accepts two variables num1 and num2
as an input from user and display num1 and num2 interchange the
values of each other using the temp variable.
Practical No. 20
Task: Write a program that accepts two variables num1 and num2
as an input from user and display num1 and num2 interchange the
values of each other not using any other variable.
Practical No. 21
Task: Write a program that accepts four digit number as input from
the user decomposes it into first, second, third and fourth digit.
Fourth digit number is accepted in variable num, first digit is stored
in variable fd, second digit is stored in variable sd, third digit is
stored in variable td while the fourth digit is stored in variable frd.
For Example if num= 7869 then fd=7, sd=8, td=6 and frd = 9.
Practical No. 22
Task: Write a program that accepts four digit number as input from
the user decomposes it into first, second, third and fourth
digit(reverse order). Fourth digit number is accepted in variable
num, first digit is stored in variable fd, second digit is stored in
variable sd, third digit is stored in variable td while the fourth digit
is stored in variable frd. For Example if num= 7869 then fd=9,
sd=6, td=8 and frd = 7.
Practical No. 23
Task: Write a program that accepts a three digit number from the
user and display it in reverse order. It also displays the difference
between actual and reversed number. Variable num stores actual
number, ud stores unit digit, td stores tens digit, hd stores hundred
digit, rev stores reversed digit while diff stores their difference.

You might also like