Difference between two similar program

Having issue with triangle with angle problem in Home » Compete » Getting started Practice Contest(in DSA learn)

in this problem i have submitted two program both similar but one wrong one right. want to know difference between them.(It is logical error).

#include
using namespace std;

int main() {
// your code goes here
short int a,b,c;
cin>>a>>b>>c;

if(a>0&&b>0&&c>0){
    
if((a+b+c)==180){
cout<<"YES";
}

}
else{
cout<<"NO";
}

return 0;

}

and other one is
#include
using namespace std;

int main() {
// your code goes here
short int a,b,c;
cin>>a>>b>>c;

if(a>0&&b>0&&c>0&&(a+b+c)==180){
        cout<<"YES";
     }
    else{
        cout<<"NO";
    }


return 0;

}

Let me know what is logical error between them

hi nisha. how u are ? i help you. plz share question + solution link correctly

there is logic error.

if(..)   // if it true then go inside
{
  if(..) // if tru then go inside
  {
  }
  // but if false then no output printed
 // so u cover these case too
}

if a>0 and b>0 and c>0 and if a+b+c is not 180 then it will not print anything in the first code.

In first program, you are not printing for the case (a+b+c) != 180 inside the if statement.

i already tell the answer first before you. why u copy my answer and tell

@nishabisht223 if u have any error, u ping me anytime. always redy to help :smiling_face_with_three_hearts:

because you didn’t write the else statement with the same hierarchy , if you put the else inside then everything fine , IG