O
O
O_9762020-12-03 18:46:46
C++ / C#
O_976, 2020-12-03 18:46:46

How to fix this error in Visual Studio / C++?

{
  setlocale(LC_ALL, "ru");
  double a, b, c, diagonal, diametr, radius;

  cout << "Введите 3 стороны прямоугольного параллелепипеда: ";
  cin >> a >> b >> c;
  cout << "Введите радиус круга: ";
  cin >> radius;
  {
    diametr = 2 * radius;
    cout << "diametr-" << diametr << endl;

    diagonal = sqrt(a ^ 2 + b ^ 2 + c ^ 2);//   ВОТ ЗДЕСЬ У МЕНЯ ПОДЧЕРКИВАЕТ "А" И "2"


//BUT IF I USE "INT" AND NOT "DOUBLE" THERE IS NO ERROR.. PLEASE TELL ME HOW TO CORRECT THIS LINE.
Throws error:
Error E2140 expression must be an unscoped integer or enum type.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
6
6db, 2020-12-03
@O_976

Either the pow function or raising by a*a

diagonal = sqrt((a * a) + (b * b) + (c * c));
diagonal = sqrt(pow(a, 2) + pow(b, 2) + pow(c, 2));

A
Alexander Ananiev, 2020-12-03
@SaNNy32

Exponentiation is done by the pow function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question