Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Specifer



Header file



" ; " after loop



Working with switch case



Comment




Function_ area of a rectangle




// AHF C PROGRAM SOLVING

//The problem are solving here using FUNCTION

#include<stdio.h> #include<math.h> #define pf printf //function declaration float fact(float a, float b, float c, float d); void main() { float x1,x2,y1,y2,res; pf("Enter the value of x1,x2,y1,y2: "); scanf("%f %f %f %f",&x1,&x2,&y1,&y2); //function call res=fact(x1,x2,y1,y2); pf("\nAREA= %f",res); return 0; } //function definition float fact(float a, float b, float c, float d) //function header //function body { float l,w,p; l=sqrt(pow((b-a),2)+pow((d-c),2)); w=sqrt(pow((b-a),2)+pow((d-c),2)); p=l*w; return p; //return answer }
OUTPUT:


© 2018 - All rights reserved