You are on page 1of 3

MADHAV UNIVERSITY

Pindwara, Sirohi (Rajasthan)

Lab Manual

Introduction to Programming Lab.

PGDCA-113 p

Department of CSA
Lab Exercise: 1
1. Write a program to perform the addition of two numbers and displays its result.

Aim: To perform the addition of two numbers and displays its result using C language

Algorithm:
1. Start
2. Declare Variables: n1,n2, sum
3. Read the values n1,n2
4. Calculate sum=n1+n2
5. Display result : sum
6. Stop

Flowchart:

Coding:

#include<stdio.h>
 main()
{
Int a, b, sum;
 Printf ("Enter two numbers to add:\n");
scanf("%d%d",&a,&b);
sum = a + b;
 printf("Sum of entered numbers = %d\n",sum);
 return 0;
}

Output:
Enter two numbers to add:
5 7
Sum of entered numbers=12
Lab Exercise: 2

2. Write a program to calculate the simple interest.

Aim: To calculate the simple interest using C language

Algorithm:
1. Start
2. Declare Variables: p (int),t(int),r(float),si(float)
3. Read the values p,r,t
4. Calculate si=(p*r*t)/100
5. Display result : si
6. Stop

Flowchart:

Coding:

#include<stdio.h>
void main()
{
int p,t;
float r, si;
clrscr();
printf(“Enter the values of principle and year \n”);
scan(%d%d”,&p,&t);
printf(“Enter the value of rate \n”);
scanf(%f”,&r);
si=(p*r*t)/100;
printf(“Simple interest=%f”,si);
getch();
}
Output:
Enter the values of principle and year
10000
3
Enter the value of rate
4.5
Simple interest=1350.0000

You might also like