Lab No:02: Title: Solving Complex Problems. Objective

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Lab No:02

Title: Solving Complex Problems.

Objective:
The students will be able to enhance their analyzing and problem-solving skills and use the same
for writing programs in C.

In lab Tasks:
Task 1 (Integers and float Conversion):
a) Write a program to take 2 integers, divide them and see the result (e.g 5/2 and 2/5)
b) Write a program to take 1 float and 1 integer value, divide them and see the result (e.g 5.0/2
and 2.0/5)

Task 2:
Determine the hierarchy of operations and evaluate the following expressions, assuming that i is
an integer variable.
i=2*3/4+4/4+8-2+5/8

Task 3:
The length & breadth of a rectangle are input through the keyboard. Write a program to calculate
the area & perimeter of the rectangle.

Task 4:
Ramesh’s basic salary is input through the keyboard. Her dearness allowance is 50% of basic
salary, and house rent allowance is 30% of basic salary. Write a program to calculate her gross
salary.

Task 5:
Two numbers are input through the keyboard into two locations C and D. Write a program to
interchange the contents of C and D.(swapping)

Post Lab Tasks:

Task 1: (type conversions in assignments)


Observe the result of arithmetic statement, assumed that a is a real variable.
(a=2/9 , 2.0/9 )

Task 2: Write a program that calculate the value of simple interest by taking the values of p, n
and r as an input, where formula for simple interest is given below.
si = (p ∗ n ∗ r)/100

Task 3:
Two numbers are input through the keyboard into two locations C and D. Write a program to
interchange the contents of C and D without using the third variable (Swapping).

You might also like