HELP WITH PROGRAM! Beginer in C++

The task is to do a program in C++ that you have to put 3 angles for the triangle.
If all angles are 60, then printf isosceles.
If the three angles add up to 180 and two are the same then isosceles
If three add up 180 and no two angles are the same, scalene.
If the three do not add up to 180, Output error

Please help!
Have been stuck for hours

Thanks
What have you written so far? This program only requires if/else-if statements to solve.
I have this so far

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void)
{
int "%a", "%b", "%c";
printf("Enter angle a: ");
scanf("a");
printf("Enter angle b: ");
scanf("b");
printf("Enter angle c: ");
scanf("c");
if (a == b && b == c && c == a)
printf(" Equilateral Triangle");
else if (a == b || b == c || c == a)
printf("Isosceles Triangle");
else
printf("Scalene Triangle");

getchar();

return 0;

}
I get what to do, but I do not know how to put it into the program
The task specifically requires you to write in C++, so why are you limiting yourself to C?

mechanical1990 wrote:
I get what to do, but I do not know how to put it into the program
Ok, explain it in English and I'll show you example translations into C++.
Last edited on
I am sorry it is in C, to run in visual studio express 2015 or visual studio.

Write a C program that reads in three angles (in degrees) and outputs the appropriate triangle type:
-If all three angles are 60, output equipateral
-If the three angles add up 180 and exactly two of the angles are the same, then outpu isosceles triangle.
-If the three angles add up to 180 and no two angles are the same, ouput scalene triangle.
-If the three angles do not add up to 180, output error.

Thanks,
I am so confuse
Yes it has to be in C.
Odd, Visual Studio 2015 has the best C++ support out of all the Visual Studio versions. Oh well.

Still, what I have said still stands: just write the program in English first and then translate that into C.
It would be like:

Angle: a, b , c
If all three angles a, b, c are equal
Write Equilateral Triangle
If a is equal to be, but not c,
Write Isosceles Triangle
If the sum of a,b,c equal 180 but different angles
Write Scalene Triangle
If the sum of a, b, c >180
Write Error
mechanical1990 wrote:
If a is equal to be, but not c,
What about when a is equal to c but not b? What about when b is equal to c but not a?
#include<stdio.h>

int main()
{
int a,b,c;
printf("enter angle values for a,b,c");
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a==60 && b==60 && c==60)
printf("equilateral triangle");
else if(((a+b+c)==180) && ((a==b)||(a==c)||(b==c)))
printf("isosceles triangle");
else if(((a+b+c)==180) && ((a!=b)||(a!=c)||(b!=c)))
printf("scalene triangle");
else if((a+b+c)>180)
printf("error");
while(1);
return 0;

}



this works..if u using visual studios....u can remove that while(1);

enjoy programming
Last edited on
@imii: Please don't post full solutions to homework problems - the point of homework is to learn how to do it yourself, and you are ruining someone's ability to learn that by just giving them the solutions directly.
Last edited on
@LB ..sorrry i LAST week joined so didnt knew ab categories. so i will keep in mind .
Topic archived. No new replies allowed.