1. X=01110 and Y=11001 are two 5 bit numbers represented in 2’s complement format. Find the sum of X and Y in 2’s complement form in 8-bit representation.
2. a. Define self-complementing code with example.
b. Subtract by using BCD code 357-298
3. a. Design X-OR gate using minimum number NAND gates. b. Explain how X-NOR gate acting as buffer and inverter.
Denominations - 3
Write a program to find the minimum number of notes required for the amount M. Available note denominations are 500, 50, 10, 1.
Input
The first line is a single integer M.
Output
Print M in denominaitons.
Explanation
Given
M = 1543, it can be written as1543 = 3*(500) + 3*(50) + 0*(10) + 1*(3)Then the output should be
500: 3 50: 0 10: 4 1: 3
Sample Input 1
1543
Sample Output 1
500: 3 50: 0 10: 4 1: 3
Sample Input 2
1259
Sample Output 2
500: 2 50: 5 10: 0 1: 9
Day Name - 2
Given the weekday of the first day of the month, determine the day of the week of the given date in that month.
The first line is a string D. The second line is an integer N.
Output
The output should be a string.
In the given example,
D = Monday. As the 1st of the day of the month is a Monday, it means the 7th and 14th of the month will be Sundays (A week has 7 days). So the 16th day (N = 16) of the month will be a Tuesday.
So, the output should be
Tuesday.
Sample Input 1
Monday
16
Sample Output 1
Tuesday
Sample Input 2
Tuesday
17
Sample Output 2
Thursday
3-digit Armstrong Number
Write a program to check if a given 3-digit number X is an Armstrong number or not.
Note: A number is an Armstrong number if the number is equal to the sum of the Nth power of its digits.
Input
The first line is an integer X.
Output
The output should be a single line containing True if it satisfies the given conditions, False in all other cases.
Explanation
In the given example
X = 371, The number of digits in 371 is 3. So, 33 + 73 + 13 = 371. Hence,
371 is an Armstrong number.
So, the output should be
True.
Sample Input 1
371
Sample Output 1
True
Sample Input 2
351
Sample Output 2
False
Compute Hypotenuse
Write a program to find the hypotenuse H of a right-angled triangle of sides A and B.
Note: Pythagoras theorem states that, for a right-angled triangle. Hypotenuse2 = A2 + B2Input
The first line is an integer, A. The second line is an integer, B.
Output
The output should be an integer.
In the given example, the first side
A = 3, and the second side B = 4. To calculate the hypotenuse we use Pythagoras theorem.
According to Pythagoras theorem, hypotenuse2 = 32 + 42
Therefore, the hypotenuse value is
5. So, the output should be 5.
Sample Input 1
3
4
Sample Output 1
5
Sample Input 2
12
5
Sample Output 2
13
Uncommon Number
Given a number N, find whether the number is common or uncommon. A number is considered uncommon if it is not divisible by any of the single-digit primes.
Input
The first line of input is an integer N.
Output
The output should be a single line containing True if it satisfies the given conditions, False in all other cases.
Explanation
In the given example,
N = 5633 the number is not divisible by 2, 3, 5, 7. So, the number is an uncommon number.
Therefore, the output should be
True.
Sample Input 1
5633
Sample Output 1
True
Sample Input 2
1000
Sample Output 2
False
Consider the following infix expression
Q: ((A+C)*D)ꜛ(B+F/E)+G use POLISH Algorithm to translate Q into its equivalent postfix expression P.
Let A, B, C, D, E, F, G, H be eight data items with the following assigned weights:
Data item: A B C D E F G H
Weight: 20 7 11 17 5 10 24 6
Construct Binary tree using Huffman Algorithm also find the path length of the tree.
Write a program which displays a given character, n number of times, using a function. When the n value is not provided, it should print the given character 80 times. When both the character and n value is not provided, it should print ‘*’ character 80 times.
By using default arguments
Static data members of a class occupy memory once whereas non static data members occupy members as per the number of objects created. Justify the statement by writing a program.