Tuesday, December 30, 2014

Math(1)

1:
#include<stdio.h>
#include<math.h>
///***triangle
int main(){
    float a,b,c;
    float s,area;
    printf("Enter size of each sides of triangle:");
    scanf("%f%f%f",&a,&b,&c);
    s = (a+b+c)/2;
    area = sqrt(s*(s-a)*(s-b)*(s-c));
    printf("Area of triangle is: %.2f",area);
    return 0;
}


output: depend on your value

2:
#include<stdio.h>
///***rectangle
int main(){
    float l,w;
    float area;
    printf("Enter size of each sides of the rectangle : ");
    scanf("%f%f",&l,&w);
    area = l * w;
    printf("Area of rectangle is: %.2f",area);
    return 0;
}


output: depend on your value 


3:
#include <stdio.h>
#define PI 3.141
///***circle
int main(){
float r, area;
printf("Please enter Radius of circle: ");
scanf("%f", &r);
area = PI * r * r;
printf("Area of cirle is:%.2f\n", area);
return 0;
}

output: depend on your value

No comments:

Post a Comment