Hello , i'm almost new on C++ , i've been following lessons but they seem the same with different words from another coding language i learned in school .
I wanted to make a simple program which will ask you to choose a shape ( triangle or etc...) .
But i get this error when i try to compile .
Code:
Compiler: Default compilerExecuting g++.exe...
g++.exe "C:\Dev-Cpp\cpp\surfaces.cpp" -o "C:\Dev-Cpp\cpp\surfaces.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Dev-Cpp\cpp\surfaces.cpp: In function `int main()':
C:\Dev-Cpp\cpp\surfaces.cpp:21: error: expected primary-expression before "else"
C:\Dev-Cpp\cpp\surfaces.cpp:21: error: expected `;' before "else"
Execution terminated
My C++ code (sry for wrong english on it but its a priv work xD) ::
Code:
#include <iostream>using namespace std;
int main()
{
int triangle, square ;
cout << "Choose your shape=";
if( triangle > square );
{
int base, height, sum;
cout << "Enter the base of triangle here=" ;
cin >> base;
cout << "Enter the height of triangle here=" ;
cin >> height;
sum = base * height / 2 ;
cout << "The Surface of the triangle is=";
cout << sum;
system ("PAUSE");
return 0;
}
else( square > triangle );
{
int length, width, sum;
cout << "Enter the length of square here=" ;
cin >> length;
cout << "Enter the width of square here=" ;
cin >> width;
sum = length * width;
cout << "The Surface of the square is=";
cout << sum;
system ("PAUSE");
return 0;
}
}