You are on page 1of 5

LAB MANUAL

LAB # 2
STATEMENT NO : 1
Get two integer from user as input and calculate and print their
sum, difference, product, quotient and remainder.

ALGORITHM :-
Step1: Declare two variable a and b.
Step2: Take values from user and store in a and b.
Step3: Now apply arithmetic operation on a and b that’s (+,-,/,*,%).
Step4: Print their result.

PROGRAM :-
OUTPUT :-

STATEMENT NO : 2
Ali basic salary is entered through the keyboard. If his house rent
allowance is 40 percent of basic salary and transport allowance is 20
percent of basic salary. Then write a program that determines his gross
salary.

ALGORITHM :-
Step1: Daclare four variable (salary, houserent,
transportallowence,grossSalary) .
Step2: Take salary from user.
Step3: Calculate 40 percent house rent of basic salary by using
formula(salary*0.4) and save it in variable houserent.
Step4: Calculate 20 percent transport allowance of basic salary by
using formula(salary*0.2) save it in variable transportallowance.
Step5: Apply operation
(grossSalary=houserent+transportallowance+salary ) to find gross
salary.
Step6: Print grossSalary.

PROGRAM :-

OUTPUT :-

STATEMENT N0 : 3
Ali’s Interchange the content of two variables using a third variable as
swapper.
ALGORITHM :-
Step1: Declare three variable a, b and c.
Step2: Now swap a and b variable using variable c.
Step3: Initialize a and b. c variable is third variable.
Step4: In order to swap a and b use operation
c=a;a=b;b=c;
Step5: Print a, b and c.
PROGRAM :-

OUTPUT :-

You might also like