The area of a rectangle is its length times its height. Write a C program that i
ID: 3923008 • Letter: T
Question
The area of a rectangle is its length times its height. Write a C program that inputs two floating point numbers from the keyboard that represent the length and the height of a rectangle. Your program should output the area of the rectangle. If you use the type double to declare your variables, you will need to use the % If format code with scanf. See the back cover pages of your book. If you use the type float to declare your variables, you will need to use the % f format code with scanf. The function printf, on the other hand, use % f for both double and float types. These little tidbits are in your textbook.Explanation / Answer
#include<stdio.h>
#include<conio.h>
int main()
{
float length, height, area;
printf("Enter length of Rectangle ");
scanf("%f", &length);
printf("Enter height of Rectangle ");
scanf("%f", &height);
area = length * height;
printf("Area of Rectangle : %0.2f ", area);
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.