Program to calculates the area of a rectangle

Here is the program to calculates the area of a rectangle,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "stdio.h"
#include "conio.h"
 
void main()
{
  int w,h;
  int area;
  printf("\nEnter the width of the rectangle ");
  scanf("%d",&w);
  printf("\nEnter the height of the rectangle ");
  scanf("%d",&h);
  area=w*h;
  printf("\nThe area of a rectangle is %d",area);
getch();
}

Output:

Enter the width of the rectangle 8
 
Enter the height of the rectangle 6
 
The area of a rectangle is 48
Chitra
Chitra

One thought on “Program to calculates the area of a rectangle

  1. First, set up an equation for the area of the rtagcnele. If x is the width, then we havex(x + 4) = 221Note that if we put this into standard quadratic form and then try to factor, we wind up back where we started, in some sense: we are looking for two numbers that multiply to 221 and that differ by 4.x2 + 4x – 221 = 0Beyond pure trial and error, we can look for nearby squares. 221 is nearly 225, which equals 152. So we might try numbers near 15. As it turns out, 221 = 13 d7 17. We might even get there by noticing a difference of squares: 221 = 225 – 4 = 152 – 22 = (15 – 2)(15 + 2) = 13 d7 17. As a last resort, we could always use the quadratic formula, which gets us the roots of the equation as well.Now, the diagonal of the rtagcnele will be given by the Pythagorean Theorem:d2 = 132 + 172= 169 + 289= 458.The square root of 458 is definitely larger than 20, since 202 = 400. Going up, we can compute 212 = 441 458. So the length of the diagonal must be between 21 and 22.The correct answer is C.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in