Answer the question
In order to leave comments, you need to log in
How to fix the error in this code?
#include <iostream>
using namespace std;
int main()
{
const int N = 5;
float A[N], C[N];
float MIN, MIN2, X;
int i;
i = 0;
A[0] = MIN;
C[0] = MIN2;
for (i; i < N; i++)
{
cout << "VVOD A:";
cin >> A[N];
cout << "VVOD C:";
cin >> C[N];
}
for (i=1; i < N; i++)
{
if (A[i] < MIN)
{
MIN = A[i];
}
}
for (i = 1; i < N; i++)
{
if (C[i] < MIN2)
{
MIN2 = C[i];
}
}
X = (MIN + MIN2) / 2;
cout << "sredne arifmeticeskoe naimenshih:" << X;
}
Answer the question
In order to leave comments, you need to log in
The MIN variable is not initialized, while you use it in the condition. Same thing with MIN2. Give them initial values
You are assigning the first element of your array the value of an uninitialized variable.
Here:A[0]
MIN
A[0] = MIN;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question