Assignment 2
Assignment 2
Question16:
Get a four-digit number from user and only reverse the last two digits of the number, then
print the number.
Conditional
1 4
Arithmetic Operations Example 1:
Input: 9561 Output 5961.
Example 2:
Input: 3859 Output: 8359
Question17:
Get a two-digit number from user and make the one’s digit as 0,then print it.
Conditional
2 4
Arithmetic Operations Example 1:
Input: 95 Output 90.
Example 2:
Input: 18 Output:10.
Question18:
Get a two-digit number from user and make the ten’s digit 1, then print it.
Conditional
3 4
Arithmetic Operations Example 1:
Input: 95 Output 15.
Example 2:
Input: 82 Output: 12.
Question19:
Get a three-digit number from user and make the one’s digit as 2, then print it.
Conditional
4 4
Arithmetic Operations Example 1:
Input: 695 Output 692.
Example 2:
Input: 182 Output: 182.
Question20:
Get a three-digit number from user and make the ten’s digit as 0, then print it.
Conditional
5 4
Arithmetic Operations Example 1:
Input: 695 Output 605.
Example 2:
Input: 182 Output: 102.
Question21:
Get a number from user and subtract 5 from that number if the number is odd, then print
the result. Do not use “if”.
Conditional
6 5
Operations Example:1
Input: 695 Output 690.
Example:2
Input: 182 Output: 182.
Question22:
Get a number from user and subtract 5 from that number if the number’s ten’s position digit
is odd, then print the result. Do not use “if”.
Conditional
7 5
Operations Example:1
Input: 685 Output 685.
Example:2
Input: 89172 Output: 89167.
Question23:
Get a two digit number from user and subtract 5 from that number if the sum of the digits of
Conditional the number is odd, then print the result. Do not use “if”.
8 5
Operations
Example:1
Input: 95 Output 95.
Example:2
Input: 72 Output: 67.
Question24:
Get a three-digit number from user and subtract 5 from that number if one’s digit number
Conditional and 100’s digit number are same, then print the result. Do not use “if”.
9 5
Operations
Example:1
Input: 595 Output 590.
Example:2
Input: 372 Output: 372.
Question25:
Get a four-digit number from user and subtract 5 from that number if ten’s digit position
Conditional and 100’s digit position is same, then print the result. Do not use “if”.
10 5
Operations
Example:1
Input: 7595 Output 7595.
Example:2
Input: 3772 Output: 3767.
Question26:
Get a two-digit number from user. If the sum of the digits is 10 then print- “Success”,
otherwise print “Failure”.
Conditional
11 5
Operations Example:1
Input: 56 - Output: Failure.
Example:2
Input: 37 - Output: Success.
Question27:
Get a three-digit number from user. If the sum of the digits is 10 then print “Success”,
otherwise print “Failure”.
Conditional
12 5
Operations Example:1
Input: 956 - Output: Failure.
Example:2
Input: 127 - Output: Success.
Question28:
Get a three-digit number from user. If the sum of the one’s digit and hundred’s digit is less
Conditional than 10, then print “Success”, otherwise print “Failure”.
13 5
Operations
Example:1
Input: 569 - Output: Failure.
Example:2
Input: 315 - Output: Success.
Question29:
Get a four-digit number from user. If the sum of the ten’s digit and hundred’s digit is greater
Conditional than 10, then print “Success”, otherwise print “Failure”.
14 5
Operations
Example:1
Input: 7529 -Output: Failure.
Example:2
Input: 9386 -Output: Success.
Question30:
Get a four-digit number from user. If the sum of the ten’s digit and hundred’s digit is equal
Conditional to 10, and one of the digits is more than 7 then print “Success”, otherwise print “Failure”.
15 5
Operations
Example:1
Input: 4649 - Output: Failure.
Example:2
Input: 9286 - Output: Success.