Showing posts with label C Program to calculate the Area of the Triangle by using its three sides. Show all posts
Showing posts with label C Program to calculate the Area of the Triangle by using its three sides. Show all posts

Program to print table of given number

//Program to print table of given number
#include<stdio.h>
#include<conio.h>
int main()
{
 int n,k=1,m;
 clrscr();
 printf("Enter the number\n");
 scanf("%d",&n);
 while(k<11)
 {
   m=n*k;
   printf("%d*%d=%d\n",n,k,m);
   k++;
 }

  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 Calculate the Distance between two Co-Ordinates

//Program to Calculate the Distance between two Co-Ordinates
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  float x1,x2,y1,y2,d;
  clrscr();
  printf("Enter the co-ordinates of the two Points\n");
  scanf("%f%f%f%f",&x1,&x2,&y1,&y2);
  d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  printf("The Distance between two Points is = %f",d);
 
  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 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.