GDTURN - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: notsoloud
Testers: tabr, yash_daga
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

Chef and Chefina roll a pair of dice, and obtain values X and Y respectively.
A turn is good if the sum of the numbers they obtain is greater than 6. Is this turn good?

EXPLANATION:

The problems boils down to: given two numbers, check if their sum is greater than 6.

This can be done using an if condition:

  • If X+Y \gt 6, print Yes.
  • Otherwise, print No.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    x, y = map(int, input().split())
    print('Yes' if x+y > 6 else 'No')

Can anyone please help me do this code in C?

1 Like

This is a basic task, the pseudocode is listed in the above post

I suggest you first take up a C course Learn C - CodeChef

Solution
#include <stdio.h>

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        int x, y;
        scanf("%d %d", &x, &y);
        if (x + y > 6) printf("YES\n");
        else printf("NO\n");
    }
}