ATM compiler c4.3.2

#include<stdio.h>

int main()

{
	float x;
	int y;
	scanf(%d",&y);
		scanf("%f",&x);
	if(y%5==0&&(x-y)>0.5)

		printf("%0.2f",(x-(y+0.5)));

	else if(y%5!=0&&(x-y)>0.5)

		printf("%0.2f",x);

	else

		printf("%0.2f",x);

	return 0;
} 

Please suggest what is wrong woth this source code?

1 Like

Your code gives wrong answer due to a very small mistake.

The mistake is the following condition:

if(y%5==0&&(x-y)>0.5)

You are missing an equal to ‘=’ sign

The correct condition is :

 if(y%5==0&&(x-y)>=0.5)

The rest of the things are absolutely fine :slight_smile:

2 Likes

still I am getting compile error…

1 Like

You are getting compilation error as the scanf statement(6-th line) in ur code miss the symbol "

scanf(%d",&y); // U are missing       "     symbol on the left of %d

The correct syntax is

scanf("%d",&y);
2 Likes

Can you mention what error is being shown? For compilation errors it usually shows which line of the code is wrong and what the problem might be.

//