Please help me find what's the problem in my code

Question link : Contest Page | CodeChef

My code :
Why is it showing wrong answer ?


using namespace std;

int main(){

int a , b, c;

cin >> a >> b >> c;

if (a+b+c == 180){

    cout << "YES" << endl;

} else {

    cout << "NO";



Hello ishika
i think you should check some other condition for traingle like (a+b)>=c or (b+c)>=a or (c+a)>=a .
for better understanding see below My code.

#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define lli long long int
#define vi vector<lli>
#define pb push_back
#define mp map<string,lli>
#define pq priority_queue<lli>
#define ss set<lli>
#define mpp map<lli,lli>
#define MP map<char,lli>
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define test lli t;cin>>t;while(t--)
using namespace std;
int main()
    int a,b,c;
    if((a+b+c)==180 && a!=0 && b!=0 && c!=0)
        if((a+b>=c) || (b+c)>=a || (c+a)>=b)

above code working fine.

// Solving in C language

#include <stdio.h>
#include <conio.h>

int main(){

int a, b, c;
printf("Enter three numbers:\n");
scanf("%d %d %d",&a,&b,&c);

if (a+b+c==180){
else {


// I’m new here == :blush:!

1 Like

First thing what are the criteria for forming a triangle…
a) sum of all angles should be equal to 180 degrees.
b.) each angle should be greater than zero (as the question says to form a valid triangle).

Meanwhile Logic:-

if((a+b+c) == 0 and a!=0 and b!=0 and c!=0) //satisfies then it will form a valid triangle
else // no triangle formed.