Friday, November 21, 2014

C area shapes pro



C Program to find area and circumference of circle

#include
#include
 int main()
{

   int rad;
   float pi = 3.14, area, ci;

   printf("\nenter radius of circle: ");
   scanf("%d", &rad);

   area = pi * rad * rad;
   printf("\narea of circle : %f ", area);

   ci = 2 * pi * rad;
   printf("\ncircumference : %f ", ci);

   return (0);
}

Output

Enter radius of a circle : 1
Area of circle : 3.14
Circumference  : 6.28

C Program to Calculate Area of Scalene Triangle


#include
#include
 int main()
 {
   int s1, s2, angle;
   float area;
   printf("\nenter side1 : ");
   scanf("%d", &s1);
   printf("\nenter side2 : ");
   scanf("%d", &s2);
   printf("\nenter included angle : ");
   scanf("%d", &angle);
   area = (s1 * s2 * sin((m_pi / 180) * angle)) / 2;
   printf("\narea of scalene triangle : %f", area);
   return (0);
}

Output

Enter Side1 : 3
Enter Side2 : 4
Enter included angle : 30
Area of Scalene Triangle : 3.000000

C Program for Beginners area of Square

#include
#include
#include
int main()
{
   int side;
   float area, r_4;
    r_4 = sqrt(3) / 4;
    printf("\nenter the length of side : ");
   scanf("%d", &side);
   area = r_4 * side * side;
   printf("\narea of equilateral triangle : %f", area);
   return (0);
}

Output
Enter the Length of Side : 5
Area of Equilateral Triangle : 10.82

C Program to Calculate Area of Right angle Triangle


#include
#include
 int main()
 {
   int base, height;
   float area;
   printf("\nenter the base of right angle triangle : ");
   scanf("%d", &base);
   printf("\nenter the height of right angle triangle : ");
   scanf("%d", &height);
   area = 0.5 * base * height;
   printf("\narea of right angle triangle : %f", area);
    return (0);
}

Output
Enter the base of Right Angle Triangle   : 4
Enter the height of Right Angle Triangle : 8
Area of Right Angle Triangle : 16.0

No comments:

Post a Comment