Advertisement
Guest User

Compiling error

a guest
May 28th, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(int argc, char** argv)
  5. {
  6.     int first_num, second_num, operator, result;
  7.     count << "Введите число: ";
  8.     cin >> first_num;
  9.  
  10.     count << "Введите второе число: ";
  11.     cin >> second_num;
  12.  
  13.     count << "Введите оператор который выхоте использовать: (+, -, *, /)"
  14.     cin >> operator;
  15.  
  16.     if (operator == '+'){
  17.         result = first_num + second_num;
  18.         count << "Сумма чисел: " << result << endl;
  19.     } else if (operator == '-'){
  20.         result = first_num - second_num;
  21.         count << "Разность двух чисел: " << result << endl;
  22.     } else if (operator == '*') {
  23.         result = first_num * second_num;
  24.         count << "Произведения двух чисел: " << result << endl;
  25.     } else if (operator == '/') {
  26.         result = first_num * second_num;
  27.         count << "Деления двух чисел: " << result << endl;
  28.  
  29.     } else {
  30.         count << "Вы ввели неправильный оператор! Повторите попытку запустив программу ещё раз!" << endl;
  31.     }
  32. }
  33.  
  34.  
  35. ====================ОШИБКА КОМПИЛЯТОРА С++====================
  36. third.cpp: In function ‘int main(int, char**):
  37. third.cpp:6:42: error: expected initializer before ‘result’
  38.     6 |     int first_num, second_num, operator, result;
  39.       |                                          ^~~~~~
  40. third.cpp:7:5: error: ‘count’ was not declared in this scope
  41.     7 |     count << "Введите число: ";
  42.       |     ^~~~~
  43. third.cpp:16:20: error: expected ‘)’ before string constant
  44.    16 |     if (operator == "+"){
  45.       |        ~           ^~~~
  46.       |                    )
  47. third.cpp:16:24: error: cannot resolve overloaded function ‘operator==’ based on conversion to type ‘bool
  48.    16 |     if (operator == "+"){
  49.       |                        ^
  50. third.cpp:17:9: error: ‘result’ was not declared in this scope
  51.    17 |         result = first_num + second_num;
  52.       |         ^~~~~~
  53. third.cpp:19:27: error: expected ‘)’ before '-'
  54.    19 |     } else if (operator == '-'){
  55.       |               ~           ^~~~
  56.       |                           )
  57. third.cpp:19:31: error: cannot resolve overloaded function ‘operator==’ based on conversion to type ‘bool
  58.    19 |     } else if (operator == '-'){
  59.       |                               ^
  60. third.cpp:20:9: error: ‘result’ was not declared in this scope
  61.    20 |         result = first_num - second_num;
  62.       |         ^~~~~~
  63. third.cpp:22:27: error: expected ‘)’ before '*'
  64.    22 |     } else if (operator == '*') {
  65.       |               ~           ^~~~
  66.       |                           )
  67. third.cpp:22:31: error: cannot resolve overloaded function ‘operator==’ based on conversion to type ‘bool
  68.    22 |     } else if (operator == '*') {
  69.       |                               ^
  70. third.cpp:23:9: error: ‘result’ was not declared in this scope
  71.    23 |         result = first_num * second_num;
  72.       |         ^~~~~~
  73. third.cpp:25:27: error: expected ‘)’ before '/'
  74.    25 |     } else if (operator == '/') {
  75.       |               ~           ^~~~
  76.       |                           )
  77. third.cpp:25:31: error: cannot resolve overloaded function ‘operator==’ based on conversion to type ‘bool
  78.    25 |     } else if (operator == '/') {
  79.       |                               ^
  80. third.cpp:26:9: error: ‘result’ was not declared in this scope
  81.    26 |         result = first_num * second_num;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement