Please Fill out the Feedback Form for Code Radius

Sum OR Difference : DIFFSUM | CodeChef Solution

1 min read

Problem

Write a program to take two numbers as input and print their difference if the first number is greater than the second number otherwise print their sum.

Input Format

  • First line will contain the first number (N1N1)
  • Second line will contain the second number (N2N2).

Output Format

Output a single line containing the difference of 2 numbers (N1 - N2)(N1−N2) if the first number is greater than the second number otherwise output their sum (N1 + N2)(N1+N2).

Constraints

−1000≤N1≤1000
-1000 \leq N2 \leq 1000−1000≤N2≤1000

Sample

Input
82 28
Output
54

Explanation

Solution

cpp
#include <iostream> using namespace std; // Solution from : Code Radius [ https://radiuscode.blogspot.com/ ] int main() { int x,y; cin>>x>>y; if(x>y){ cout<<x-y<<endl; } else cout<<x+y<<endl; return 0; }

Please First Try to Solve Problem by Yourself.

You may like these posts

  •  ProblemWrite a program to obtain length (L) and breadth (B) of a rectangle and check whether its area is greater or perimeter is greater or both are equal. Please Share thi…
  • ProblemYou and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into h…
  • ProblemAlice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice…
  •  ProblemChef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play a single song on a loop. Today, …
  •  ProblemChefland has 2 different types of coconut, type A and type B. Type A contains only x_a milliliters of coconut water and type B contains only x_b grams of coconut pulp.…
  • ProblemIf Give an integer N . Write a program to obtain the sum of the first and last digits of this number. Please Share this article... Input Format The first line contains a…

Post a Comment