My program stops working during execution

-4

I write my code in code blocks and I get this runtime error during execution:

Process returned (0xC0000005)

This is my code

I believe it has something to do with the way I call my functions

main:

int main()
{
    int LT[101],i, NI;
    float x;
for (i=0 ; i<101 ; i++)
LT[i]=i*i;
NI=find_NI(LT , x);
x=recieve_check_x();
cout<<"square root  of x is:"<<(NI+(x-LT[NI])/(2*NI));
return 0;
}

rec_chk.cpp:

#include <iostream>
#include "funcs_hd.h"
using namespace std;
float recieve_check_x ()
{
    float x;
cout<<"enter the value of x:"<<endl;
cin>>x;
while (x<0 or x>10000)
    {
    cout<<"\a error! x must be within range of [0,10000]"<<endl;
    cout<<"enter another value:"<<endl;
    cin>>x;

    }

    }

find_NI:

#include <iostream>
#include "funcs_hd.h"
#include <cstdlib>
#include <cmath>
using namespace std;
 int find_NI (int LT[] , float x)
 {
 int i, j , NI;
 j=i+1;
 double i_delta=abs(LT[i]-x);
 double j_delta=abs(LT[j]-x);
 if (i_delta<j_delta)
    NI=LT[i];
    else
    NI=LT[j];
    return NI;
 }

funcs_hd:

#ifndef FUNCS_HD_H_INCLUDED
#define FUNCS_HD_H_INCLUDED

float recieve_check_x (void);
int find_NI (int [] , float);
#endif // FUNCS_HD_H_INCLUDED

I get an error code and the program stops running

c++
asked on Stack Overflow Jan 8, 2019 by Armin E • edited Jan 8, 2019 by kvantour

1 Answer

4
int i, j , NI;
j=i+1;
  ^ indeterminate value

You read an indeterminate value in the program. Therefore the behaviour of the program is undefined.

answered on Stack Overflow Jan 8, 2019 by eerorika

User contributions licensed under CC BY-SA 3.0