Ticker

6/recent/ticker-posts

CPNM LAB PROGRAM --1


cpnm lab 1 programming made by ece⚡the⚡wonders ***THANK YOU***

----------------------------------------------------------------------------------------------
1. Write a program to read x, y coordinates of 3 points and then calculate the area of a triangle formed by them and print the coordinates of the three points and the area of the triangle. What will be the output from your program if the three given points are in a straight line? 
----------------------------------------------------------------------------------------------
FLOW CHART :-
Algorithm:

Step – 1 : Start
Step – 2 : Read the values of the three coordinates 
Step – 3 : Print the values of X coordinate
Step – 4 : Print the values of Y coordinate
Step – 5 :  Calculate Area = 0.5 * fabs (x1 * (y2 – y3)+ x2 * (y3 – y2) +x3 * (y1 – y2))
Step – 6 :Print the area
Step – 7 : If area = 0.Print the points are collinear otherwise points are not collinear
Step – 8 : Stop


PROGRAM :-

#include <stdio.h>

int main()
{
int x1,x2,x3,y1,y2,y3;
float area;

printf("enter the values of x1,x2,x3  :");
scanf("%d%d%d",&x1,&x2,&x3);

printf("enter the values of y1,y2,y3  :");
scanf("%d%d%d",&y1,&y2,&y3);
printf("---------------------------\n");
area=0.5*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2));
 printf("the x coordinates are :\n");

printf("x1=%d\tx2=%d\tx3=%d\n",x1,x2,x3);
printf("---------------------------\n");
printf("the y coordinates are :\n");

printf("y1=%d\ty2=%d\ty3=%d\n",y1,y2,y3);
printf("---------------------------\n");
printf("the area of triangle is =%.2f\n",area);
printf("-------------------------------------------------------------------------------------\n");
printf("thank you for using our code this code is created by ECE THE WONDERS (Hemu The Smart)\n");
printf("-------------------------------------------------------------------------------------\n");

if (area==0)
{ printf("the given coordinates lies in a stright line");}

else 
{ printf("the given coordinates does not lie in a stright line");}
return 0;
}


opt :- 



-: DON'T TRY TO COPY AND PASTE THE CODE .SELECTION OF CODE IS DISABLED :-

Post a Comment

0 Comments