Program to delete duplicates from a link list

Decrement OR Increment | Codechef solution

Problem of Decrement OR Increment | Codechef solution:-

Write a program to obtain a number N

N

and increment its value by 1 if the number is divisible by 4 otherwise

otherwise

decrement its value by 1.

Input of Decrement OR Increment | Codechef solution:

  • First line will contain a number N
    N
     

    .

Output:

Output a single line, the new value of the number.

Constraints

  • 0N1000
    0≤N≤1000
     

Sample Input:

5

Sample Output:

4

EXPLANATION:

Since 5 is not divisible by 4 hence, its value is decreased by 1.

Code:-

#include <iostream>
using namespace std;
int main()
{
   int n;
   cin>>n;
   if(n%4==0)
      cout<<n+1;
   else
      cout<<n-1; 
    return 0;
}

 

Recommended Post:

Leave a Reply

Your email address will not be published.