Friday, August 16, 2019

WAP for calculation of perimeter and area of a rectangle.

// C program

#include<stdio.h>
int main()
{
    int l,b,a,p;
    printf("Enter the value of length and breadth:");
    scanf("%d %d",&l,&b);
    p=2*(l+b);
    a=l*b;
    printf("\nThe perimeter of a rectangle=%d",p);
    printf("\nThe area of a rectangle=%d",a);
    return 0;
}

Sample Input/Output:

Enter the value of length and breadth:10
5

The perimeter of a rectangle=30
The area of a rectangle=50

 
    

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...