Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Specifer



" ; " after loop



Comment



Test expression



Header file




Given four co-ordinates and find the area of a rectangle



// AHF C PROGRAM SOLVING

//solving here basic type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int x1,x2,x3,x4,y1,y2,y3,y4; float length,wigth,area; pf("Enter the first co-ordinates(x1,y1): "); scanf("%d %d",&x1,&y1); pf("Enter the second co-ordinates(x2,y2): "); scanf("%d %d",&x2,&y2); pf("Enter the third co-ordinates(x3,y3): "); scanf("%d %d",&x3,&y3); pf("Enter the fourth co-ordinates(x4,y4): "); scanf("%d %d",&x4,&y4); length=sqrt(pow((x1-x2),2)+pow((y1-y2),2)); length=sqrt(pow((x3-x4),2)+pow((y3-y4),2)); wigth=sqrt(pow((x1-x4),2)+pow((y1-y4),2)); wigth=sqrt(pow((x2-x3),2)+pow((y2-y3),2)); area=length*wigth; pf("\n\nLENGTH= %.2f",length); pf("\nWIGTH= %.2f",wigth); pf("\n\nTHE AREA OF THE TRY-ANGLE= %.2f",area); return 0; }
OUTPUT:


© 2018 - All rights reserved