C Program to Determine the Centre Coordinate in C Programming Language

In this C programming tutorial, we will learn how to find center Coordinate in C programming language. This C Program read the x and y coordinates of the vertex and also read a Length of aside.

C Program to Determine the Centre Coordinate in C Programming Language

#include<stdio.h>
int main()
{
int x,y,z;
printf("Enter the x-coordinate of the vertex of the triangle\n");
scanf("%d",&x);
printf("Enter the y-coordinate of the vertex of the triangle\n");
scanf("%d",&y);
printf("Enter the length of a side of the triangle\n");
scanf("%d",&z);
printf("The centre is : (%d,%d)",(x+(z/2)),(y+(z/2)));
return 0;
}

Output:

Enter the x-coordinate of the vertex of the triangle                                                                          
2                                                                                                                             
Enter the y-coordinate of the vertex of the triangle                                                                          
3                                                                                                                             
Enter the length of a side of the triangle                                                                                    
2                                                                                                                             
The centre is : (3,4)

In the above C program, we learn how to find the center of a triangle using the C programming language.

Leave a Comment

Your email address will not be published. Required fields are marked *