About the editorial category

Find official solutions for any problem on CodeChef.

5 Likes

what is this?

2 Likes

And why is this pinned right now?

lol

#include
using namespace std;

int main(){
int x;
cin>>x;
float y;
cin>>y;
if(x%5==0){
if(y>=(x+0.50))
y= y-(x+0.5);
cout<<y;
}
return 0;
}
why this is giving me error

what is the error???

add the standard libraries in the first line.
include

wtf

you have to import (Iostream) Library

include

in the top

The code you provided is encountering an error because of a syntax issue and possibly a logical error. Let’s go through it:

  1. Syntax Issue: You’re missing a semicolon after if(y>=(x+0.50)).
  2. Logical Issue: The code doesn’t handle the case where x is not divisible by 5. If x is not divisible by 5, the program will exit without printing anything. You might want to add an else statement to handle this case.
    Here’s the corrected version of your code:

include
using namespace std;
int main() {
int x;
cin >> x;
float y;
cin >> y;
if (x % 5 == 0) {
if (y >= (x + 0.50))
y = y - (x + 0.5);
cout << y;
} else {
cout << y; // Or you can print an error message
}
return 0;
}

This version includes the necessary semicolon and also handles the case where x is not divisible by 5 by printing the value of y in that case.

the code you provided is incorrect error