fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. double a,b,c,answer,x,y,z;
  5. cout<<"Square (1) or rectangle (2) ";
  6. cin>>x ;
  7. if (x==1)
  8. {
  9. cout<<"Square side: ";
  10. cin>>a;
  11. cout<<" Type (2) if you would like to calculate the Perimeter or (1) if you would like to calculate the surface?";
  12. cin>>y;
  13. if (y==1)
  14. {
  15. cout<<"The surface of the square is: ";
  16. answer = ( a * a );cout << answer<<endl;
  17. }
  18. else if (y==2)
  19. {
  20. cout<<"The perimeter of the square is: ";
  21. answer = (4*a);cout << answer<<endl;
  22. }
  23.  
  24. else if (x==2)
  25. {
  26. cout<<"The first side of the rectangle is: ";
  27. cin>>c;
  28. cout<<"The second side of the rectangle is: ";
  29. cin>>b;
  30. cout<<" Type (2) if you would like to calculate the Perimeter or (1) if you would like to calculate the surface? ";
  31. cin>>z;
  32. if (z==1)
  33. {
  34. cout<<"The surface of the rectangle is: ";
  35. answer = (c*b);cout << answer<<endl;
  36. }
  37. else if (z==2)
  38. {
  39. cout<<"The perimeter of the rectangle is: ";
  40. answer = 2*(c+b);cout << answer<<endl;
  41. }
  42. }
  43. system("pause");
  44. return 0;}
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4: error: expected initializer before ‘double’
prog.cpp:5: error: expected constructor, destructor, or type conversion before ‘<<’ token
prog.cpp:6: error: expected constructor, destructor, or type conversion before ‘>>’ token
prog.cpp:7: error: expected unqualified-id before ‘if’
stdout
Standard output is empty