Code Competitions

Coding competition

Sunday, 12 May 2013

Program to find areas of circle, triangle and rectangle.


#include<stdio.h>
#include<conio.h>
void main()
{
    float a,c,r,p,l,b;
    int ch;
    clrscr();
    printf("1. find the area and circumfrence of a circle");
    printf("\n2. find area of triangle");
    printf("\n3. find area of rectangle\n");
    scanf("%d",&ch);
    switch(ch)
    {
        case 1:
        {
            printf("\nenter the value of r");
            scanf("%f",&r);
            a=3.14*r*r;
            c=2*3.14*r;
            printf("\nthe area of circle %f",a);
            printf("\nthe circumference of %f",c);
            break;
        }
        case 2:
        {
            printf("\nenter the base and parimeter of triangle");
            scanf("%f%f",&b,&p);
            a=(b*p)/2;
            printf("\narea of triangle %f",a);
            break;
        }
        case 3:
        {
            printf("enter the length,bredth of rectangle");
            scanf("%f%f",&l,&b);
            a=l*b;
            printf("area of rectangle %f",a);
            break;
        }
    }
    getche();
}


No comments:

Post a Comment