import java.util.*; public class Main { public static void main(String args[]) { int x,y,z; boolean p; Scanner s = new Scanner(System.in); System.out.print("Input the first number: "); x = s.nextInt(); System.out.print("Input the second number: "); y = s.nextInt(); System.out.print("Input the third number: "); z = s.nextInt(); p=((x + y) == z || (y + z) == x || (z + x) == y); if(p==true) { System.out.println("sum of two numbers equals the third number"); } else { System.out.println("sum of two numbers not equals the third number"); } } }
Input the first number: 5
Input the second number: 10
Input the third number: 15
sum of two numbers equals the third number
def myfun(): x=int(input("Input the first number: ")) y=int(input("Input the second number: ")) z=int(input("Input the third number: ")) p=((x + y) == z or (y + z) == x or (z + x) == y); if(p==True): print("sum of two numbers equals the third number") else: print("sum of two numbers not equals the third number") if __name__=="__main__": myfun()
Input the first number: 5
Input the second number: 10
Input the third number: 15
sum of two numbers equals the third number
#include <stdio.h> int main() { int x,y,z,p; printf("Input the first number: "); scanf("%d",&x); printf("Input the second number: "); scanf("%d",&y); printf("Input the third number: "); scanf("%d",&z); p=((x + y) == z || (y + z) == x || (z + x) == y); if(p==1) { printf("sum of two numbers equals the third number"); } else { printf("sum of two numbers not equals the third number"); } return 0; }
Input the first number: 5
Input the second number: 10
Input the third number: 15
sum of two numbers equals the third number