c++ pico and online shell

I used a c++ online shell to do my coding and my class professor wants us to use pico to the programming. when I transferred my codes to pico, the code wouldn't run at all while two different online shells worked perfectly fine.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  #include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int
main ()
{
  int variable;


  cout <<
    "<1>calculate area of circle \n<2> calculate area of rectangle\n<3> calculate area of triangle\n";
  cout << "type the number of your desired option:\t";
  cin >> variable;



  if (variable == 1)
    {
      double circle;
      float area;
      float radius;
      const double pi = 3.14159;


      cout << "Enter the radius of circle : ";
      cin >> radius;
      area = pow (radius, 2) * pi;

      cout << "Area of circle with radius " << fixed << setprecision (2) <<
	radius << " is " << area << fixed << setprecision (2);


    }
  else if (variable == 2)
    {
      double rectangle;
      float area;
      double length;
      double width;

      cout << "Enter the length of rectangle:";
      cin >> length;
      cout << "Enter the width of rectangle:";
      cin >> width;
      area = length * width;

      cout << "Area of rectangle is " << fixed << setprecision (2) << area;

    }
  else if (variable == 3)

    {
      double triangle;
      float area;
      double base;
      double height;

      cout << "Enter the base of the triangle:";
      cin >> base;
      cout << "Enter the height of triangle:";
      cin >> height;
      area = 0.5 * base * height;

      cout << "Area of triangle is " << fixed << setprecision (2) << area;


    }

  else
    {
      cout << "error";

    }

  return 0;
}
Do you mean pico, the programming language? http://pico.vub.ac.be/
pico the editor for C++. it fails for compiling my code
What compiler (and what version) do you use?
What is the error message?
Editors do not compile. Compilers do. Editor might call some compiler as a convenience.

If compiler cannot compile some code, then it will give error messages. Those messages are informative.
If you type in the shell:

ls -> Enter
pico programname.cpp -> Enter
c++ programname.cpp -> Enter

(If you have g++ compiler, this command looks a little different)
g++ programname.cpp -> Enter

What happens? Any error messages?

If no, and you type:

ls -> Enter

Are there two files now? One called programname.out and another, your original source file?

If there is an .out file and you type in:

./programname.out -> Enter

Does it run? Any errors?
Last edited on
for online C++ shells this program runs fine . and i think both shell and pico uses C++ 14 so i dont know why pico is unable to compile it
this is what the error messages are for pico

area_calculator.cpp:13:8: missing terminating " character
area_calculator.cpp: In function `int main()':
area_calculator.cpp:14: error: syntax error before `area'
area_calculator.cpp:14: error: stray '\' in program
area_calculator.cpp:14:29: missing terminating " character
and also im using UW PICO(tm) 4.8 for compiler

those are the error messages for the pico compiler and this program runs for two other online c++ shells. that i use , which are ;

https://www.onlinegdb.com/#

and http://cpp.sh/


If you have copy pasted the code from the web browser make sure it does not contain additional invisible characters. This doesn't seem to be a problem with this website (at least not for me) so you could try copying the code from your post here in this topic and see if it works better.
@Peter87, as far as I remember, if it is invisible characters, then the message would rather be error: stray '\302'. (Please correct me!)

In this case, and as the error is pointing towards lines 13 and 14, it suspects code, but finds none. So, the most likely fix should be to write:

cout << "<1>calculate area of circle\n";
cout << "<2> calculate area of rectangle\n";
cout << "<3> calculate area of triangle\n";
cout << "type the number of your desired option:\t";

and line 29, it should be:

area = PI * pow(radius, 2);

If this does not work, maybe it is worth to try:
area = 3.1415926 * radius * radius;

Or, if this doesn't work, and pico complains:
area = 3.1415926*(radius*radius);
hi perter i resolve that problem but now i have a problem with how output looks .

gen242@cs04:~> ./area_calculator
<1> calculate area of circle
<2> calculate area of rectangle
<3> calculate area of triangle
type the number of your desired option: 3
Enter the base of the triangle:3
Enter the height of triangle:4
Area of triangle is 6.00gen242@cs04:~>

so the output is showing without the carriage return where i bolded it
Add << "\n" or << endl << endl; at the end of the line which outputs the area. Whichever works best. ;-)
the output is showing without the carriage return where i bolded it

It's because you didn't output a newline character at the end.
Last edited on
thank you i really appreaciate the help!
Topic archived. No new replies allowed.