Https://www.codechef.com/viewsolution/55181201

https://www.codechef.com/viewsolution/55181201
Problem Code:CHN15A
It is showing a runtime error. I dot understand why?

int arr[j];

β†’
int arr[a];

2 Likes

Pay attention to compiler warnings!

[simon@simon-laptop][18:34:48]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling dudu_0-CHN15A.cpp
Executing command:
  g++ -std=c++17 dudu_0-CHN15A.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG    -fsanitize=undefined -ftrapv
dudu_0-CHN15A.cpp: In function β€˜int morgi(int, int)’:
dudu_0-CHN15A.cpp:7:14: warning: β€˜j’ is used uninitialized in this function [-Wuninitialized]
    7 |     int arr[j];
      |              ^
Successful

Thanks bro!!

thanks bro!!but still i am getting the error