Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why can't run this functoins at this compiler?

–3 votes
asked Dec 24, 2020 by Aibaq (110 points)
#include<iostream>

using namespace std;

int showmenu();

float area(double rad);

float area(float side);

float area(float length, float width);

void main()

{

int x;

float arr, side, length, width;

double radius;

x = showmenu();

if (x == 1)

{

cout << "Enter the radius of the circle: ";

cin >> radius;

arr = area(radius);

}

else if (x == 2)

{

cout << "Enter the length of the side of the sqaure: ";

cin >> side;

arr = area(side);

}

else if (x == 3)

{

cout << "Enter the length of the side of the rectangle: ";

cin >> length;

cout << "Enter the width of the side of the rectangle: ";

cin >> width;

arr = area(length, width);

}

else

{

cout << "Incorrect choice" << endl;

return;

}

cout << "Area = " << arr << endl;

system("pause");

}

int showmenu()

{

int ch;

cout << "Enter 1 to calculate area of a circle." << endl;

cout << "Enter 2 to calculate area of a square." << endl;

cout << "Enter 3 to calculate area of a rectangle." << endl;

cout << "Enter your choice: ";

cin >> ch;

return ch;

}

float area(double rad)

{

float area;

area = (22 * rad * rad) / 7;

return area;

}

float area(float side)

{

float area;

area = side * side;

return area;

}

float area(float length, float width)

{

float area;

area = length * width;

return area;

}

2 Answers

0 votes
answered Dec 24, 2020 by Khaled Albanna (140 points)

The reason of this error is because your source code contains non-ascii characters. Perhaps source code is copied from somewhere else, where double quotes are written in unicode character format.
For example, instead of "Hello" it has “Hello”
Note that second hello is written inside double quotes which is in unicode format, which compiler  can't understand
 .To resolve error, replace unicode quotes with ascii quot

0 votes
answered Dec 25, 2020 by loknath panday (140 points)
this code will throw error because   system("pause")   function is not defined .
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...