Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Test expression



" ; " after loop



Iterative statement



Header file



Specifer




Calculate area of a rectangle, triangle and circle



// AHF C PROGRAM SOLVING

//solving here basic type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { double radius,a,b,height,width,res1=0.0,res2=0.0,res3=0.0; //area for circle pf("\nEnter value for circle.............."); pf("\nEnter the radius of the circle: "); scanf("%lf",&radius); res1=3.1416*radius*radius; //area for triangle pf("\nEnter value for triangle.............."); pf("\nEnter the first length: "); scanf("%lf",&a); pf("\nEnter the second length: "); scanf("%lf",&b); res2=.5*a*b; //area for rectangle pf("\nEnter value for rectangle.............."); pf("\nEnter the height: "); scanf("%lf",&height); pf("\nEnter the width: "); scanf("%lf",&width); res3=height*width; //total output pf("\nThe area of the circle is : %lf",res1); pf("\nThe area of the triangle is = %lf",res2); pf("\nThe area of the rectangle is = %lf",res3); return 0; }
OUTPUT:


© 2018 - All rights reserved