Decrement OR Increment Solution

Problem

Write a program to obtain a number N and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1.

Input:

  • First line will contain a number N.

Output:

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

Constraints

  • 0 \leq N \leq 1000

Sample Input:

5

Sample Output:

4
### EXPLANATION:

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



Program :

 #include<stdio.h>

int main()

{

    int a;

    scanf("%d",&a);

    if(a%4==0)

    printf("%d",++a);

    else

    printf("%d",--a);

}

Post a Comment

0 Comments