Saturday, 5 March 2022

2. Find the area and perimeter of square and rectangle. Input the side(s) through the keyboard.

/* 2. find the area and perimeter of square and ractangle.
        input the side(s) through the keyboard */


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

void main()
{
    float len, wid, area, perimeter;
    clrscr();

    printf("enter lenth for square: ");
    scanf("%f",&len);

    area = len * len;

    perimeter = 4 * len;

    printf("\n\narea of square is: %0.2f",area);
    printf("\nperimeter of square is: %0.2f",perimeter);


    printf("\n\nenter lenth and width for ractangle:\n");
    scanf("%f %f",&len,&wid);

    area = len * wid;

    perimeter = 2 * (len + wid);

    printf("\n\narea of ractangle is: %0.2f",area);
    printf("\nperimeter of ractangle is: %0.2f",perimeter);

    getch();
}

/*      output:

enter lenth for square: 12


area of square is: 144.00
perimeter of square is: 48.00

enter lenth and width for ractangle:
12
16


area of ractangle is: 192.00
perimeter of ractangle is: 56.00


*/ 

No comments:

Post a Comment

python programs

1. sum of two number