PROGRAM 1. If length and breadth of rectangle are entered through keyboard , write a program to find area and perimeter of rectangle .
CODING-:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,area,perimeter;
printf(“Enter length and breadth of triangle \n”);
scanf(“%f%f”,&l,&b);
area = l*b;
perimeter = 2*l+2*b;
printf(“Area of rectangle is %f\n”, area);
printf(” Perimeter of rectangle is %f\n”, perimeter);
getch();
}
PROGRAM 3. Similiarly write program to find area of triangle, circle.
PROGRAM 2. WAP to swap two numbers.
CODING-:
#Include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,m,temp=0;
printf(“Enter the values of n and m\n”);
scanf(“%d%d”,&n,&m);
printf(“Values of n and m before swapping is %d,%d\n”, n, m);
temp=n;
n=m;
m=temp;
printf(“values of n and m after swapping is %d,%d\n”, n, m);
getch();
}
How it worked ?
- Here we want to interchange two numbers . So first we have declared variables which values we want to interchange , and a third variable which we will use to exchange values.
- First value of n and m are entered through keyboard through scanf().
- Now see the statement temp=n; , here we are assigning value of n in third variable temp.
- Next n=m; , here value of m get assigned in n.
- Finally m=temp; , here we assign value of m to temp.
- Look at the following picture to understand properly.

Leave a comment