pls tell me what is wrong i this program i am stuck at it always it is showing wrong why??


    #include <iostream>
    using namespace std;
    
    int main() 
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    	float c;
    	long int h,ts;
    	cin>>h>>c>>ts;
    	if(h>50&&c<0.7&&ts>5600)
    	{cout<<"10"<<endl;}
    	else if(h>50&&c<0.7)
    	{cout<<"9"<<endl;}
    	else if(c<0.7&&ts>5600)
    	{cout<<"8"<<endl;}
    	else if (h>50&&ts>5600)
    	{cout<<"7"<<endl;}
    	else if ((h>50 &&c>=0.7 && t<=5600)||(h<=50 && c<0.7 && t<=5600) ||(h<=50 && c>=0.7 && t>5600))
    	{cout<<"6"<<endl;}
    	else
    	{cout<<"5"<<endl;}
    	}
    	return 0;
    }

Gagan …the code you submitted isn’t formatted well…click edit and just before the start of your code, type
< code >(dont add the spaces) so that it formats well, its an html tag…and from now on you can use the option of entering your code (its a picture with binaries).
Secondly provide the link of your problem as well…and if possible show exactly what the error is.

I’m not checking what’s wrong but I think it’s better if you use flags. You may need to add 3 int or bool variables but it will remove the redundancies on checking the states.

You are getting wrong ans coz of the condition 6. You have written t in place of all ts. Correct it and it will work like a charm :slight_smile:
Here’s your solution with correction : link

P.S. Sorry for directly copy pasting your code, but my intention was to check whether it works :slight_smile:

2 Likes

ok ok thanks for telling


also my program is in all submissions

in starting you will see my program with wrong sigh

You are right. The code can be shortened!

1 Like

ooooooh. Nice spotting dear. I felt his problem was somewhere along the floating comparisons.

2 Likes

Thanks. Lucky catch :wink:

omg no no you do the right thing thank u so much i was so furstated with it but you found it thnku brother

1 Like

Haha happens mate. Happy coding :slight_smile: