Write a program to find the area of rectangle

// Write a program to find the area of rectangle
// Ex: lenght: 3, breadth: 5 ->Area:15

 
#include
int main(){
    double l,b;
    printf("Enter the length of Rectangle:");
    scanf("%lf",&l);
    while(l<=0){
        printf("Length can't be negative or zero\n");
        printf("Enter the length of Rectangle:");
        scanf("%lf",&l);        
    }
    printf("Enter the breadth of Rectangle:");
    scanf("%lf",&b);
    while(b<=0){
        printf("Breadth can't be negative or zero\n");
        printf("Enter the breadth of Rectangle:");
        scanf("%lf",&b);        
    }
    
    // calculating area of rectangle
    double area = l*b;
    printf("\nArea of rectangle: %.2lf",area);
    getch();
}

No comments:

Post a Comment