I believe I am having some problems with my compiler. I believe everything is written correctly, and I was wondering if someone can give me heads up. Maybe I need a new compiler? or I saved the file incorrectly? or it's my operating system/computer.
-----------------------------------------------------------------------------------
COMPILER ERROR-----------------------------------------Code:#include<stdio.h> #include<math.h> int main(void) { do { float a, b, c, s, area; char answer, y, Y, n, N; printf("Enter the first side of the triangle: "); scanf_s("%f", &a); printf("Enter the second side of the triangle: "); scanf_s("%f", &b); printf("Enter the third side of the triangle: "); scanf_s("%f", &c); if ( a + b > c) || ( b + c > a) || ( a + c > b) { s = (a + b + c) / 2; area = sqrt(s * (s-a) * (s-b) * (s-c)); printf("Area = %f\n", area); if ( a== b ) || ( b == c ) || ( a == c ) { printf("Its an Isosceles Triangle\n"); printf("Do you wish to continue with a new triangle?<y/n>"); scanf_s("%c", &answer); } else if ( a == b ) && ( b == c ) { printf("Its an Equilateral Triangle\n"); printf("Do you wish to continue with a new triangle?<y/n>"); scanf_s("%c", &answer); } else { printf("Its an Scalene Triangle\n"); printf("Do you wish to continue with a new triangle?<y/n>"); scanf_s("%c", &answer); } } while ( answer != y ) || ( answer != Y ) || ( answer != n ) || ( answer != N ) { printf("You have made an invalid selection...\n"); printf("Do you wish to continue with a new triangle?<y/n>"); scanf("%c, &answer"); } } while (answer == y || answer == Y); } return 0; }
------ Build started: Project: triangles lab1b, Configuration: Debug Win32 ------
triangles.cpp
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(23): error C2143: syntax error : missing ';' before '||'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(23): warning C4390: ';' : empty controlled statement found; is this the intent?
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(24): error C2143: syntax error : missing ';' before '{'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(28): error C2143: syntax error : missing ';' before '||'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(28): warning C4390: ';' : empty controlled statement found; is this the intent?
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(29): error C2143: syntax error : missing ';' before '{'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(34): error C2181: illegal else without matching if
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(34): error C2143: syntax error : missing ';' before '&&'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(34): warning C4390: ';' : empty controlled statement found; is this the intent?
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(35): error C2143: syntax error : missing ';' before '{'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(40): error C2181: illegal else without matching if
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(47): error C2143: syntax error : missing ')' before '!'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(47): error C2065: 'y' : undeclared identifier
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(47): error C2059: syntax error : ')'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(47): error C2143: syntax error : missing ')' before '!'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(47): error C2059: syntax error : ')'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(48): error C2143: syntax error : missing ';' before '{'
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(53): error C2065: 'y' : undeclared identifier
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(53): error C2065: 'Y' : undeclared identifier
c:\temp\triangles lab1b\triangles lab1b\triangles.cpp(53): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========