Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to calculate area of rectangle and circle

Posted By: Felipe Reed     Category: C Programming     Views: 14321

Write a program to calculate area of rectangle and circle

Code for Program to calculate area of rectangle and circle in C Programming

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

#define pi 3.142857
main()
{
    char ans = 'y';
    float length, breadth, circumference, arear, perimeter, radius, areac;
    clrscr();
    do
    {
        clrscr();
        printf("\n    Rectangle    \n");
        printf("\nPlease enter length       := ");
        scanf("%f", &length);
        fflush(stdin);

        printf("\nPlease enter breadth      := ");
        scanf("%f", &breadth);
        fflush(stdin);

        arear = length * breadth;
        printf("\nThe area of rectangle are := %5.3f\n", arear);

        printf("\n    Circle        \n");
        printf("\nPlease enter radius := ");
        scanf("%f", &radius);
        fflush(stdin);

        circumference = 2 * pi * radius;
        printf("\nThe circumference of the circle := %f\n", circumference);

        areac = (pi * radius) * radius;
        printf("\nThe area of the circle          := %f", areac);

        printf("\n");
        printf("\nEnter any more (Y/N)            := ");
        scanf("%c",&ans);
        fflush(stdin);
        if (ans == 'y' || ans == 'Y')
        {
            continue;
        }
        elseif (ans == 'n' || ans == 'N')
        {
            exit(0);
        }
    } while (ans == 'y' || ans == 'Y');
            getch();
            return;
}
  
Share: 


Didn't find what you were looking for? Find more on Program to calculate area of rectangle and circle Or get search suggestion and latest updates.

Felipe Reed
Felipe Reed author of Program to calculate area of rectangle and circle is from Philadelphia, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!