+ 2
Hovercraft c++ approach
Test case 3,4 showing failure ,can anybody tell why !! int n ; cin >>n; if (n<7) { cout<<"Loss"; } if (n==7) { cout<<"Broke Even"; } else{ cout<<"Profit"; } And what's your approach for that
4 Respostas
+ 2
Try to put 5
Output: LossProfit
How to fix?
1. You can use switch and case statements
2. You can use ternary operator
3. You can put 'else if (n == 7)' instead of 'if (n == 7)'
+ 4
if( profit > 0){
return "Profit";
}
if( profit < 0 ){
return "Loss";
}
return "Broke Even";
}
+ 3
🗡️Jasprit I will apply your method , and let you know
+ 1
Try else if (n == 7)