A program to check two given integers and returns true if at least one of them is 30 or if their sum is 30.

Here, we have a basic program example to return true if either of the two integers is 30 or if their sum equals 30 using different languages. This program is created in c language, c++, Java, and Python.

Program to check if either one of the number is 30 or their sum is 30 in C language

#include <stdio.h>
int main(void){
    int num1, num2;
    printf("Enter first number: ");
    scanf("%d",&num1);
    printf("Enter second number: ");
    scanf("%d",&num2);
    printf("\n%d",test(num1, num2));
    }
   int test(int x, int y)
        {
            return x == 30 || y == 30 || (x + y == 30);
        }

Program to check if either one of the number is 30 or their sum is 30 in C++ language

#include <iostream>
using namespace std;
bool test(int x, int y)
        {
            return x == 30 || y == 30 || (x + y == 30);
        }
int main()
 {
  int num1,num2;
  cout << "enter first number: " ;
  cin>>num1;
  cout << "enter second number: " ;
  cin>>num2;
  cout<<"The result is: ";
  cout << test(num1, num2) << endl;
  return 0;
}

Program to check if either one of the number is 30 or their sum is 30 in Python language

num1=int(input("enter first number : "))
num2=int(input("enter second number : "))
if (num1 == 30 or num2 == 30) or (num1 + num2) == 30:
    print("true")
else:
    print("false")

Program to check if either one of the number is 30 or their sum is 30 in Java language

import java.util.Scanner;
class test{
  public static void main(String[] args)
    {
       int num1, num2;
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter the first number:  ");
       num1 =sc.nextInt();
       System.out.print("Enter the second number:  ");
       num2 =sc.nextInt();

   if (num1 == 30 || num2 == 30 || (num1 + num2 == 30)){
              System.out.println("true");
           }
   else{
             System.out.println("false");
            }

}
}