Showing posts with label c program to find out the area of circle. Show all posts
Showing posts with label c program to find out the area of circle. Show all posts

C Program to calculate the Area of the Triangle by using its three sides

//Program to calculate the Area of the Triangle by using its three sides
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  float area,s,a,b,c;
  clrscr();
  printf("Enter three sides of the Triangle for calculating Area\n");
  scanf("%f%f%f",&a,&b,&c);
  s=(a+b+c)/2;
  area=sqrt(s*(s-a)*(s-b)*(s-c));
  printf("\nThe Area of the Triangle is = %f",area);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

C Program To convert the temperature between Celcius and Fahrenheit

//To convert the temperature between Celcius and Fahrenheit
#include<stdio.h>
#include<conio.h>
int main()
{
 float c,f;
 int m;
 clrscr();
 printf("Enter your choice"
           "\nPress 1 to convert Temperature from Celcius to Fahrenheit"
           "\nPress 2 to convert Temperature from Fahrenheit to Celcius\n");
 scanf("%d",&m);
 switch(m)
 {
  case 1:
  printf("\nEnter the Temperature in Celcius\n");
  scanf("%f",&c);
  f=9*c/(5)+32;
  printf("\nTemperature in Fahrenheit is = %f",f);
  break;

  case 2:
  printf("\nEnter the Temperature in Fahrenheit\n");
  scanf("%f",&f);
  c=(f-32)*5/9;
  printf("\nTemperature in Celcius is = %f",c);
  break;

  default:
  printf("\nEnter valid Choice");
 }
  getch();
  return 0;
}

Program to Calculate Sum and Difference between Integers

//Program to Calculate Sum and Difference between Integers
#include<stdio.h>
#include<conio.h>
int main()
{
  int a,b;
  clrscr();
  printf("Enter two integers whose sum and difference to be calculated\n");
  scanf("%d%d",&a,&b);
  printf("The sum of two Integers is = %d",sum(a,b));
  printf("\nThe difference of two Integers is = %d",diff(a,b);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find out the area of circle by using macro

//Program to find out the area of circle by using macro
#include<stdio.h>
#include<conio.h>
#define pi 3.1416//macro
int main()
{
  float area, radius;
  clrscr();
  printf("Enter the radius of circle whose area to be calculated\n");
  scanf("%f",&radius);
  area=pi*radius*radius;
  printf("\nThe Area of the Circle is = %f",area);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.