Rahul is playing a guessing number game with computer. The objective of the game is to guess the number that computer thinks. A guess is correct when the guess exactly matches with computer number. After each guess by rahul, the computer will give a score comprising of black and white coins.
Black coin== guessed digit is present in the computer number and in same position
White coin== guessed digit is present but in another position..
Your task is to find out the no.of black and no.of.white coins.
Input: first line contains two space seperated integers denoting rahuls guess and computer number.
Input1: 1423 1234
Output: black: 1 white: 3
Input2: 1423 5678
Output: black:0 white: 0
Need correct output sir
Considering the Abstraction Principle, perform the following:
a. [2 Marks] Define an abstract class by the name of Shape, the class consists of an attribute (D) which refers to the dimension and a member function Area().
b. [2 Marks] Make the function Area a pure virtual function
c. [2 Marks] Define a class Circle which is s subclass of the superclass Shape and define the Area inside the class.
d. [1 Marks] Define a second class Square which is a subclass of Shape and define the area inside it.
JamEx Limited requires a program to calculate and print the commission received by a salesperson. The program should process an undetermined number of salespersons and appropriately terminate by a predefined input. The commission rate is based on two factors, the amount of sales and the class to which a salesperson belongs. The input will be the salesperson number, sales amount and class. The commission rate will be based on the following criteria:
Class=1
If sales is equal to or less than $1000, the rate is 6 percent.
If sales is greater than $1000 but less than $2000, the rate is 7 percent.
If the sales is $2000 or greater, the rate is 10 percent.
Class=2
If the sales is less than $1000, the rate is 4 percent.
If the sales is $1000 or greater, the rate is 6 percent.
Class=3 The rate is 4.5 percent for all sales amount
Class=any other value
Output an appropriate error message.
a) Write a method GetOneStudent that asks a student for both of his/her WRAV101 and
WRSC111 marks (each as a real number). The method must return both of these marks. The
method must ensure that each of the marks is in the range 0 to 100.
b) Write a method CanContinue that takes as input two marks, one for WRAV101 and one for
WRSC111. Each of these marks is in the range 0 to 100. The method must return the value
true if both of these marks are at least 50, otherwise the method must return the value false.
Given a linked list containing n nodes. The problem is to insert a new node
with data x at the middle of the list. If n is even, then insert the new node
after the (n/2)th node, else insert the new node after the (n+1)/2th node
Suppose we have a pointer to float data type which contains the memory address
value 100.
If we add the integer value 3 to this pointer, what will be the value of the pointer if float data
types are 4 bytes in length?
Write a C++ program that takes up to 10-digit integer input from user (can be 1 digit, 2 digit, and so on..); passes this to a function which reverses the digits. Finally, the reversed number should be displayed in the main function. For example: when user enters 10-digit like 1234567890 your function will reverse it to 987654321. Do not use strings. Be careful for big integer values. [use functions, decision control]
A number is called a happy number, if you start with the given number
and arrive at 1 by repeating the following process (as illustrated in the below example):
(a) compute the sum of the squares of given number digits
(b) if the resultant value is 1, then the number is happy number, else execute point (a) for
the newly produced number.
Note that if a number is not a happy number, there will be an endless loop to this execution.
Goal: In this question, you are required to write a recursive function that checks whether
the number entered by the user is a happy number or not for 10 cycles/iterations only. The
output shown in blue colour should be shown by the function and text in yellow colour
should be displayed by the main function.
a. Write a function convert() that converts a decimal number to a binary, octal, and
hexadecimal equivalents. The function will take two arguments: first argument will be
the number to be converted and second argument will be the base in which this number
is to be converted. Function should return the converted value. You may use strings to
represent converted numbers like “0x3A”, “00101100”, “72” etc. Lower limit must be smaller than upper limit.
b. Call convert() function in the main program to produce the following output.
Example output:
Enter upper limit = 20
Enter lower limit = 10
Decimal Binary Octal Hexadecimal
10 00001010 12 0xA
11 00001011 13 0xB
12 00001100 14 oxC
13 00001101 15 0xD
14 00001110 16 0xE
15 00001111 17 0xF
16 00010000 20 0x10
17 00010001 21 0x11
18 00010010 22 0x12
19 00010011 23 0x13
20 00010100 24 0x14