Monday, April 22, 2019

IO 5

  • Problem Description

    Write a program to scan the given input and perform unary prefix increment and decrement operators. Condition : Variable name to be used: Preadd, Presub, Postadd, Postsub

    Perform the following operations:
    1. Preadd = ++a
    2. Presub = --a
    3. Postadd =a++
    4. Postsub =a--
  • Test Case 1

    Input (stdin)
    2

    Expected Output
    3

    2

    2

    3
  • Test Case 2

    Input (stdin)
    7

    Expected Output
    8

    7

    7

    8
Solution

#include <stdio.h>
int main()
{
int inp=0;
  scanf ("%d",&inp);
  printf ("%d",++inp);
  printf ("\n%d",--inp);
  printf ("\n%d",inp++);
  printf ("\n%d",inp--);
return 0;
}

No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...