Which is pretty much alien language to me, hence i cannot not possibly understand what the compiler is saying. I looked up the internet , for what could be the reason and found out that i could be accessing index which has not been allocated memory, therefore i set on to make a simplest code possible and encounter the same error.
But i don't understand how i could be accessing non allocated memory. Also what could be the other reasons for the same error to occur such frequently. Best SolutionI think the issue could be your Related SolutionsC++ – the difference between #includeand #include “filename”In practice, the difference is in the location where the preprocessor searches for the included file. For 0 the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.For 1 the preprocessor searches first in the same directory as the file containing the directive, and then follows the search path used for the 0 form. This method is normally used to include programmer-defined header files.A more complete description is available in the GCC documentation on search paths. How to determine the size of the array in CExecutive summary:
Full answer: To determine the size of your array in bytes, you can use the 3 operator:
On my computer, ints are 4 bytes long, so n is 68. To determine the number of elements in the array, we can divide the total size of the array by the size of the array element. You could do this with the type, like this:
and get the proper answer (68 / 4 = 17), but if the type of 4 changed you would have a nasty bug if you forgot to change the 5 as well.So the preferred divisor is 6 or the equivalent 7, the size of the first element of the array. I got an RTE on my submission, and I've tested it (on my local machine) on a variety of test cases, including the ones on the udebug. But on my uri submission it says "timeout: the monitored command dumped core" and I'm not sure of what i did wrong. Here's the code :
Any help would be appreciated :) Thanks in advance. #includeusing namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here int i; int min=ages[i]; for (int i =0; i<5; ++i){ if ( ages[i] >min){ min = ages [i]; } } int price; price = 50 * min / 100; cout << price << endl; return 0; } |