How do I write a C program to find the diagonal of a rectangle?

 

How do I write a C program to find the diagonal of a rectangle?

Diagonal of a rectangle:-

Use pow() and sqrt() to implement the above formula d = √( l2 + w2).

The program:

  1. #include<stdio.h> 
  2. #include<math.h> 
  3. void main() 
  4. { 
  5. float d,w=20,h=10; 
  6. d = sqrt(pow(w,2)+pow(h,2)); 
  7. printf("Result Value = %f",d); 
  8. } 

Result Value = 22.360680

Comments

Popular Posts