Chapter 1 Program 2

Also visit our YouTube Channel Tech Eos    VISIT CHANNEL


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

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

void main()
{
int a , area_of_square , perimeter_of_square ;   //FOR Square

        // FOR Rectangle

int length , width , area_of_rectangle , perimeter_of_rectangle;  


clrscr();

printf("\nEnter value of a : ");
scanf("%d" , &a);

// area of square formula -->>   (a*a)

area_of_square = (a*a);

//perimeter of square formula -->> (4*a)

perimeter_of_square = (4*a);

printf("\n\nArea of Square    :  %d " , area_of_square );

printf("\nPerimeter of Square :  %d " ,                                                         perimeter_of_square);


printf("\n\nEnter value of length  : ");
scanf("%d" , &length);

printf("\nEnter value of width   : ");
scanf("%d" , &width);

// area of rectangle formula -->>  (w*l)

area_of_rectangle = (width*length);

// perimeter of rectangle formula -->>   2*(l+w)

perimeter_of_rectangle = 2*(length+width);


printf("\n\nArea of Rectangle  : %d " ,                                              area_of_rectangle );

printf("\nPerimeter of Rectangle  : %d " ,                                    perimeter_of_rectangle);

getch();
}







Comments

Popular posts from this blog

Maximum from three numbers (Nested If ) (Chapter 2 Program 2 )

( Chapter 2 Program 7 )

Modular operator in c ( Chapter 1 Program 9)