Pgdca 113p C PGM Lab
Pgdca 113p C PGM Lab
Pgdca 113p C PGM Lab
Lab Manual
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
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