Answer the question
In order to leave comments, you need to log in
Point out a bug to a 2-day programmer?
Hello. I'm quite new to programming, no experience.
In general, the compiler shows the error "error C4700: an uninitialized local variable "a" and also "b" was used.
I can not understand what to do, please point out the error.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
double a, b, sum, raz, umn, del;
sum = a + b;
raz = a - b;
umn = a*b;
del = a / b;
cout << "vvedite dannie \n";
cin >> a, b;
if (a + b)
cout << sum << "\n";
else
if (a - b)
cout << raz << "\n";
else
if (a*b)
cout << umn << "\n";
else
if (a / b)
cout << del << "\n";
else
cout << "hernyu ne nesi, dyatel. \n";
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
You are adding a and b without assigning a value to them. In C/C++, in this case, arbitrary garbage can appear in the variables. You need to write double a = 0; double b = 0;
Because the question has already been answered - let me joke the old joke:
Подходит 2-х дневный программист к senior'у и показывает неработающую программу:
- Подскажите, пожалуйста, где у меня ошибка?
- В ДНК, - вздыхает senior.
(no offense, just for fun)
#include <iostream>
using namespace std;
int main()
{
double a, b, sum, raz, umn, del;
cout << "vvedite dannie \n";
cin >> a;
cin >> b;
sum = a + b;
raz = a - b;
umn = a*b;
del = a / b;
if (a + b)
cout << sum << "\n";
else
if (a - b)
cout << raz << "\n";
else
if (a*b)
cout << umn << "\n";
else
if (a / b)
cout << del << "\n";
else
cout << "hernyu ne nesi, dyatel. \n";
system("pause");
return 0;
}</iostream>
as an option
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question