+ 1
When I run my code in a code project I get this as an output " timeout: the monitored command dumped core". What should I do?
#include <iostream> using 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; }
3 Answers
+ 2
Most likely you have been fiddling with pointers and messed something up. Without code nothing more I can say.
+ 2
** Notify after any edit or updation.
In statement :
int min=ages[i] ; will cause that error, because I=5 there and it's index out of bounds. You should use
int min=ages[ 0 ] ;
And according to your logic ,
if ( ages[I]>min)
min=ages[I]; will find maximum value. You should use
if ( ages[I] < min)
min = ages[I] ;
remove int i; u never used it.
Hope it helps...
+ 1
Thank you so much