Pass or Fail Solution

Problem

Chef is struggling to pass a certain college course.

The test has a total of N question, each question carries 3 marks for a correct answer and -1 for an incorrect answer. Chef is a risk-averse person so he decided to attempt all the questions. It is known that Chef got X questions correct and the rest of them incorrect. For Chef to pass the course he must score at least P marks.

Will Chef be able to pass the exam or not?

Input Format

  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains of a single line of input, three integers N, X, P.

Output Format

For each test case output "PASS" if Chef passes the exam and "FAIL" if Chef fails the exam.

You may print each character of the string in uppercase or lowercase (for example, the strings "pAas", "pass", "Pass" and "PASS" will all be treated as identical).

Constraints

  • 1 \leq T \leq 1000
  • 1 \leq N \leq 100
  • 0 \leq X \leq N
  • 0 \leq P \leq 3\cdot N

Sample 1:

Input
Output
3
5 2 3
5 2 4
4 0 0
PASS
FAIL
FAIL




Program :

 #include<stdio.h>

int main()

{

    int t,n,x,p,i;

    scanf("%d",&t);

    for(i=0;i<t;i++)

    {

        scanf("%d %d %d",&n,&x,&p);

        int m=x*3-(n-x);

        if(m>=p)

        printf("PASS\n");

        else

        printf("FAIL\n");

    }

}

Post a Comment

0 Comments