Attempt All Questions From This Section
Attempt All Questions From This Section
(Two Hours)
a) Distinguish between character constant and string constant with an example. [2x5]
b) Arrange the given data types in descending order of their
size: char, long, float, Boolean
c) Write the appropriate function to do the following:
1) To add two strings.
2) To take out a character from a string at any position.
d) What do you understand by Literals? Name any one. [2x5]
e) Write down the format to assign 10 names in a single dimensional array.
Question 3.
Page 1 of 3
i) A parameterized constructor to initialize data members like name, age, m1, m2, m3
ii) void compute() – to calculate the average and maximum out of three marks
iii) void display() – to display the name, age, marks in three subjects, maximum and average Write a
main() method to create an object of the class and call the above member methods.
Question 5.
The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every
book. The ISBN is based upon a 10-digit code.
The ISBN is legal if: 1xdigit 1 + 2xdigit2 + 3xdigit3 + …………….+ 10xdigit10 is divisible by 11
[15]
Example: For an ISBN 1401601499
Sum= 1x1 + 2x4 + 3x0 + 4x1 + 5x6 + 6x0 + 7x1 + 8x4 + 9x9
= 253 , which is divisible by 11.
Write a program to:
Page 2 of 3
Question 6.
Write a program to input any string to calculate the total number of characters leaving blank spaces, total
number of vowels(consider both cases) present in the string and also print the total number of words.
Example:
If sample Input: Human like Apples
[15]
Output: Total characters leaving blank spaces :- 15
Total vowels :- 6
Total number of words :- 3
Question 7.
Define a class city and store the given city name in a single dimensional array. Sort these city names in
alphabetical order using bubble sort technique only, then print the sorted list.
Sample Input: Mumbai, Kolkata, Agra, Delhi, Bangalore
Sample Output: Agra, Bangalore, Delhi, Kolkata, Mumbai
[15]
Question 8. [15]
Write a program to accept a string in lower case. Convert the first character of each word of the string to
uppercase and display the new string.
Sample input: india got independence in nineteen forty seven
Sample output: India Got Independence In Nineteen Forty Seven
Question 9. [15]
Design a class to overload a function calculation() as follows:
a) Int calculation (int n, char ch) with one integer argument and one character argument. It computes the cube
of an integer if choice ‘ch’ is ‘C’ otherwise computes its square.
b) Int calculation (int a, int b, char ch) with two integer arguments and one character argument. It
c) Computes the remainder if choice ‘ch’ is ‘R’ otherwise find the quotient.
or not. calculation (String x, String y) with two string arguments that check whether strings are equal
Boolean