Decrement OR Increment
Write a program to obtain a number and increment its value by 1 if the number is divisible by 4 decrement its value by 1.
Input:
- First line will contain a number
Output:
Output a single line, the new value of the number.
Constraints
Sample Input:
5
Sample Output:
4
EXPLANATION:
Since 5 is not divisible by 4 hence, its value is decreased by 1.
SOLUTION USING C LANGUAGE:-
#include <stdio.h> int main(void) { int N; scanf("%d",&N); if(N%4==0) N=N+1; else N=N-1; printf("%d",N); // your code goes here return 0; }
No comments:
Post a Comment