Two Subjects – pass or fail

The pass mark in a subject is 40. The marks scored in two subjects by a student is passed as the input. If the student has passed in both the subjects, the program must print pass. Else must print fail.

Example Input/Output 1:
Input:
50 60

Output:
pass

Example Input/Output 2:
Input:
34 60

Output:
fail

Python

mark1, mark2 = map(int, input().split())
if mark1 >= 40 and mark2 >= 40:
    print('pass')
else:
    print('fail')

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mark1 = sc.nextInt();
        int mark2 = sc.nextInt();
        if (mark1 >= 40 && mark2 >= 40) {
            System.out.print("pass");
        } else {
            System.out.print("fail");
        }
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int mark1, mark2;
    scanf("%d%d", &mark1, &mark2);
    if(mark1 >= 40 && mark2 >= 40)
    {
        printf("pass");
    }
    else
    {
        printf("fail");
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int mark1, mark2;
    cin >> mark1 >> mark2;
    if(mark1 >= 40 && mark2 >= 40)
    {
        cout << "pass";
    }
    else
    {
        cout << "fail";
    }
    return 0;
}
Previous Article

Multiply Two Numbers

Next Article

Mobile Signal

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *