Instructions:
Input one integer.
Print out the integer in one line.
Check whether the integer is odd or not. If it is odd, print "Odd".
Input
A line containing an integer
5
Output
The first line contains the inputted integer.
The second line contains a string which is the result.
5
Odd
Q1. Define a class Deposit that has a principal, a rate of interest, which is fixed for all
deposits and a period in terms of years. Write member functions to
(i) alter(float) which can change the rate of interest.
(ii) interest() which computes the interest and returns it.
(iii) print() which prints data as shown below. Note that the width of each column is 20.
5mks
Q2. Assume that the cell users are two kinds – those with a postpaid option and those
with a prepaid option. Postpaid gives a fixed free talk time and the rest is computed at
the rate of N2.90 per pulse. Prepaid cards have a fixed talk time.
Define a class Cell_user as a base class and derive the hierarchy of classes. Define
member functions and override them wherever necessary to
(i) retrieve the talk time left for each user.
(ii) print the bill in a proper format containing all the information for the postpaid user.
5mks
Input three integers in different lines (one each line).
Print out the integers in one line.
If the 1st integer is greater than or equal to both the 2nd integer and the 3rd integer, print "Yes".
Input
Three lines containing an integer on each.
3
2
1
Output
The first line contains all the three inputted integers.
The second line contains a string which is the result.
3·2·1
Yes
Define a class License that has a driving license number, name and address. Define
constructors that take on parameter that is just the number and another where all
parameters are present.
Input two integers in one line.
Print the two integers in one line, separate them with a space.
Print a string message on a new line, "Equal" if both integers are equal.
a. Write a function is_subset_sum that takes an integer N and an integer
array A as parameter and returns True if N is a sum of any subset of A and
returns False otherwise. You must use dynamic programming tabulation
method for calculation
b. Write a main function that takes the array A of size s as input from the
console. Then it takes N as input in a loop and prints whether there is a subset
in A that sums to N or not. Following is a sample code for that.
while(true){
cout << “Enter N: “;
cin >> N;
cout << is_subset_sum(A, N, s) << endl;
Sample input:
5
2 4 5 6 8
Enter N: 15
Enter N: 0
Enter N: 3
Sample output:
15 is a subset sum of the given array
0 is a subset sum of the given array
3 is not a subset sum of the given array
Write a function int wrong(char key[].char results[]) The function will be used to grade multiple-choice exam.
The exan has 5 questions, each answered with a letter in the range 'a', to f. All the answers for a student are stored in the character array results.
The key-answer is also stored in array key. Both arrays (results) and (key) are passed to the function wrong as parameters.
The function wrong returns the numbers of false answers given by by the student. For example if the key is-{'a','b','a','d",'e'} and the results is {'a','c','a','d','f'}. the function return 2 (since there are 2 wrong answers).
Instructions:
Input two integers in one line.
Print the two integers in one line, separate them with a space.
Print a string message on a new line, "Equal" if both integers are equal.
Output
5 5
Equal
Define a class Deposit that has a principal, a rate of interest, which is fixed for all
deposits and a period in terms of years. Write member functions to
(i) alter(float) which can change the rate of interest.
(ii) interest() which computes the interest and returns it.
(iii) print() which prints data as shown below. Note that the width of each column is 20.
�
1. Using the looping statement. Create a program that will display the following:
A. *
***
****
****
***
*
B. @@@@@@@
@
@
@
@@@@@@@