Pages

Saturday, November 12, 2011

Program to calculate area,perimeter of rectangle and circumference ,area of circle (Ref:Let us c-chapter1)

This program calculates the area and perimeter of a rectangle and circumference and area of a circle.

The length and breadth of a rectangle and radius of a circle are input through the keyboard.Write a program to calculate the area and perimeter of the rectangle,and the area and circumference of the circle.

#include<stdio.h>


void main()
{

float length,breadth,radius,rec_area,circle_area,perimeter,circumference;

clrscr();

printf("Enter length and breath for rectangle:");
scanf("%f%f",&length,&breadth);

printf("Enter radius for circle:");
scanf("%f",&radius);

rec_area=length*breadth;
perimeter=2*(length+breadth);

circle_area=3.14*radius*radius;
circumference= 2*3.14*radius;

printf("\n\nArea of rectancle is : %f",rec_area);
printf("\n\nPerimeter of rectangle is : %f",perimeter);

printf("\n\nArea of circle is : %f",circle_area);
printf("\n\nCircumference of circle is : %f",circumference);

getch();

}

No comments: