Write a C program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle

calculation of perimeter and area of rectangle in c
calculation of perimeter and area of rectangle in c

Problem Statement:

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

Answer:

/* Calculation of perimeter and area of rectangle and circle */

#include<stdio.h>
#include<conio.h>

main()
{

int l, b, r, area1, perimeter;
float area2, circum;

clrscr();
printf(“\n Enter Length and Breadth of Rectangle”);
scanf(“%d %d”,&l, &b);

area1=l*b; /*Area of rectangle */
perimeter=2*l+2*b; /* Perimeter of rectangle */

printf(“\n Area of Rectangle = %d”, area1);

printf(“\n Perimeter of Rectangle=%d”,perimeter);

Print(“\n\n Enter Radius of circle”);
scanf(“%d”,&r);

area2=3.14*r*r; /* Area of Circle */
circum=2*3.14*4; /* Circumference of a circle */\

printf(“Area of Circle=%f”,area2);
printf(“Circumference of Circle-%f”,circum);

printf(“\n\n\n\n Press any key to exit….”);
getch();

}

Related Posts

  • 42
    Problem Statement: The distance between two cities (in km.) is input through the keyboard. Write a C program to convert and print this distance in meters, feet, inches and centimeters. Answer: /* Conversion of distance */ #include <stdio.h> #include <conio.h> main() { float km, m, cm, ft, inch; clrscr(); /*…
    Tags: printf, program, write, calculate
  • 36
    Problem Statement: Write a program to calculate the salary as per the following table: Solution: /* C program to calculate salary */ main( ) { char g ; int yos, qual, sal ; printf ( "Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):" )…
    Tags: program, calculate, write
  • 34
    Write a C Program for the following :- Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. Answer:  /* To Calculate the gross salary of Ramesh…
    Tags: printf, program, write, calculate
  • 30
    The if statement can take any of the following forms: if ( condition ) do this ; if ( condition ) { do this ; and this ; } if ( condition ) do this ; else do this ; if ( condition ) { do this ; and this…
    Tags: program, write
  • 30
    Let's have an example to understand else if clause : /* else if ladder demo */ main( ) { int m1, m2, m3, m4, m5, per ; per = ( m1+ m2 + m3 + m4+ m5 ) / per ; if ( per >= 60 ) printf ( "First…
    Tags: printf, program, write

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: