Use a loop to restart a program
I've just started to learn C programming. In following program I need to use a loop, so at the end, it asks the user that if wants to try other numbers or not. If yes program restarts from beginning.Thank you for any help.
Code:
/*
A program who checks three positive integers to be 3 sides of a triangle and calculates the area and shows the triangle type.
*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int a, b, c, s, area;
printf("Input 3 positive integers: \n");
scanf("%d %d %d", &a, &b, &c);
if ((a + b <= c) || (a + c <= b) || (c + b <= a))
printf("These are not a valid triangle's sides\n %d %d %d\n", a, b, c);
else
{
{
if ((a == b) && (a == c) && (b == c))
printf("This is an equilateral triangle\n");
else if ((a == b) || (a == c) || (b == c))
printf("This is an isosceles triangle\n");
else if ((a != b) || (a != c) || (b != c))
printf("This is a scalene triangle\n");
}
s = (a + b + c) / 2.0;
area = sqrt(s*(s - a)*(s - b)*(s - c));
printf("The area of triangle is: %d \n", s);
return 0;
}
}