QUESTION 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, Posadd, Possub
TEST CASE 1
INPUT
2
OUTPUT
The Value of num=2
The Value of num++=2
The new Value of num=3
The Value of num=3
The Value of num--=3
The new Value of num=2
TEST CASE 2
INPUT
7
OUTPUT
The Value of num=7
The Value of num++=7
The new Value of num=8
The Value of num=8
The Value of num--=8
The new Value of num=7
EXPLANATION :
The code requires you to input a number and print the print the post-increment , post-decrement values of the input received from the user ( Increment and Decrement Operators ).
QUESTION ISSUES :
The question asks us to perform the " unary prefix increment and decrement " on the given user input , but the sample input output requires us to do unary postfix increment and decrement. Similarly, the variables Posadd and Possub are not required.
ALGORITHM :
SOLUTION : (Please use this as reference only)
Write a program to scan the given input and perform unary prefix increment and decrement operators. Condition : Variable name to be used: Preadd, Presub, Posadd, Possub
TEST CASE 1
INPUT
2
OUTPUT
The Value of num=2
The Value of num++=2
The new Value of num=3
The Value of num=3
The Value of num--=3
The new Value of num=2
TEST CASE 2
INPUT
7
OUTPUT
The Value of num=7
The Value of num++=7
The new Value of num=8
The Value of num=8
The Value of num--=8
The new Value of num=7
EXPLANATION :
The code requires you to input a number and print the print the post-increment , post-decrement values of the input received from the user ( Increment and Decrement Operators ).
QUESTION ISSUES :
The question asks us to perform the " unary prefix increment and decrement " on the given user input , but the sample input output requires us to do unary postfix increment and decrement. Similarly, the variables Posadd and Possub are not required.
ALGORITHM :
- Take an input form the user , print it. ( inp )
- Post increment the value of the number and print it. ( inp++ )
- Print the number again ( inp )
- Print the number again ( inp )
- Post decrement the number and print it. ( inp-- )
- Print the value of the number again ( inp )
SOLUTION : (Please use this as reference only)
CODE |
No comments:
Post a Comment