How can i solve this problem? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i solve this problem?

Please help me about this code? I found wrong answer on test case 1 and 3. My code link: https://code.sololearn.com/cE8HlcG87gz0/?ref=app Problem: https://www.sololearn.com/coach/904?ref=app Tell me,where is the wrong.

18th May 2021, 2:26 PM
Md Abu Taher
Md Abu Taher - avatar
7 Answers
+ 2
//My code #include <iostream> using namespace std; int main() { int ages[5],min; //double total=0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here double total=0.0; min=ages[0]; for(int i=0;i<5;i++){ if(ages[i]<min){ min=ages[i]; } } total=50.0-50*(min/100.0); cout<<total; return 0; } You just need to calculate the min and the discount should be min%. Read the question once again..!!
18th May 2021, 3:02 PM
sarada lakshmi
sarada lakshmi - avatar
+ 3
Remove the line total = .... Inside the loop. And write this outside of loop total=50.0-(min*50)/100.0;
18th May 2021, 3:01 PM
TOLUENE
TOLUENE - avatar
+ 2
Share code link .
18th May 2021, 2:36 PM
TOLUENE
TOLUENE - avatar
+ 1
The links you shared, both are the links of question..
18th May 2021, 2:43 PM
sarada lakshmi
sarada lakshmi - avatar
+ 1
sarada lakshmi Thanks my loving friend. Code accepted. Also thank you for helping.
18th May 2021, 3:08 PM
Md Abu Taher
Md Abu Taher - avatar
+ 1
SAYED🇧🇩🇵🇸 আপনাকে অনেক অনেক ধন্যবাদ -সাহায্য করার জন্য।❣️❣️
18th May 2021, 3:11 PM
Md Abu Taher
Md Abu Taher - avatar
0
//My code #include <iostream> using namespace std; int main() { int ages[5],min; //double total=0; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here double total=0.0; min=ages[0]; for(int i=0;i<5;i++){ if(ages[i]<min){ min=ages[i]; total=50.0-50*(ages[i]/100.0); } } cout<<total; return 0; }
18th May 2021, 2:54 PM
Md Abu Taher
Md Abu Taher - avatar