(e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

Let Us C by Yashwant Kanetkar

 
Solution By Muhammad Kaleem UIlah



                                                                  Exercise Questions 
[H] Write C programs for the following:
(e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

#include <stdio.h>

#include <stdlib.h>

 

int main()

{

    float lenght,width,radius,areaR,perimeterR,areaC,circumferenceC;

    printf("\t\tEnter The Lenght = ");

    scanf("%f",&lenght);

    printf("\n\t\tEnter the width = ");

    scanf("%f",&width);

    areaR=lenght*width;

    perimeterR=2*(lenght*width);

    printf("\n\t\tArea of the rectangle = %f",areaR);

    printf("\n\t\tPerimeter of Rectangle = %f",perimeterR);

    printf("\n\n\t\tEnter the value of radius =");

    scanf("%f",&radius);

    areaC=3.14*radius*radius;

    circumferenceC=2*3.14*radius;

    printf("\n\t\tArea of the Circle = %f",areaC);

    printf("\n\t\tCircumference of Circle = %f\n",circumferenceC);

    return 0;

}

Comments

Popular posts from this blog

EXERCISE 01 Complete Solved LET US C by Yashwant Kanetkar

(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)

(k) A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer.