OOPS Question Bank
OOPS Question Bank
Examle:
Input: AD
OutPut:ABCD.
2. Write a program to print the no of days in a month by reading the year and month.
3. Print the Multiplication table using goto.
4. Arrange the 1_D Array numbers in ascending order.
5. Print the following 3_D Pattern
1 0 0
1 1 0
1 1 1
1 0 0
1 1 0
1 1 1
1 0 0
1 1 0
1 1 1
6. Write a C program to print sum of n number without Passing argument and without return
Value.
7. Print the Factorial for 5 using recursive function.
8. Explain the basic string function and write a C program to print all the
vowels, consonant, digits and special characters from user entered string and
print the count for the same.
9. Discuss the different types of array and write a C program to print the
following pattern using goto control statement and multidimensional
array.
10.
A 0 0 0 a b c d
B C 0 0 0 e f g
D E F 0 0 0 h i
G H I J 0 0 0 j
11.Explain the syntax of the control loops and write a program to read the age
of 10 persons and count the number of persons in the age group 50 to 60 and
30 to 40. Using
a. For loop and Conditional operator/Ternary operator
b. While loop and if else structure
c. Do while and conditional operator
d. For loop and conditional operator
12. Explain the function and types of function and write a program using user
define functions to
a. Read a matrix
b. Transpose the matrix
c. Find the sum of the diagonal elements
20. Identify the appropriate storage class by reading the given information and
Narrate the respective storage class with an example code
i) A storage class retains its value even after the function execution is
complete
ii) The variable storage allocation is created only when the block is
activated and perishes immediately after the execution.
21.Write a program to display the count and the words which are only
palindrome in the given string “Nitin speaks Malayalam, Madam Arora
teaches Malayalam.
24. Create an array a[]={1,2,3,4,5}, using a pointer to find the sum on the
given array.
25. With a neat diagram, explain how a two-dimensional array is allocated in memory and
also write a program to assign values in a 5 x 5 matrix as follows:
a. (1,2,3…) in the upper triangle.
b. (a,b,c,…)in the lower triangle.
c. diagonal values are 0.
Example:
0 1 2 3 4
a 0 5 6 7
b c 0 8 9
d e f 0 10
g h i j 0
27. Identify the appropriate storage class by reading the given information and narrate the
respective storage class with an example code
i) A storage class retains its value even after the function execution is complete
ii) The variable storage allocation is created only when the block is activated and perishes
immediately after the execution.
28. Write a program to display the count and the words which are only palindrome in the
given string “Nitin speaks Malayalam, Madam Arora teaches Malayalam.
30. Details of the members of a rotary club (Name, ClubID, Age, Date of joining , amount
collected, amount donated , Level -(Diamond/Gold/Silver), position -
(member/president/treasurer/secretary) are stored and maintained by the club authorities.
On the “Rotary club day” every two years, a new cabinet is appointed. The cabinet is
made of president, treasurer and secretary. The rules for qualification are as follows:
• A president should have already served as either secretary or treasurer and should have
collected/donated more than 1 lakh rupees and should be a diamond member.
• A treasurer should have been an active member for more than 5 years and should have
collected/donated at least 50,000 rupees.
• A secretary should be a silver member with at least 2 years of active membership.
Write a C program to list the names of the members who are qualified to be in the cabinet
this year using structures.
31. Each year the Department of Traffic Accidents receives accident count reports from a
number of cities and towns across the country. Given details of ‘n’ days, develop an
algorithm and write a program to determine the average number of accidents and for each
day, print the difference between the number of accidents on that day and average.
For example, if the number of accidents is 5 and the values are 10, 12, 15, 13, 5 then
average is 11 and the difference of values are 1, 1, 4, 2, 6.
32. First year students of an institute are informed to report anytime between 25.4.23 and
29.4.23. Create a C program to allocate block and room number. Consider Five blocks
with 1000 rooms/block. Room allocation starts from Block A on first-come, first-served
basis. Once it is full, then subsequent blocks will be allocated. Define a structure with
appropriate attributes and create functions
i. to read student’s detail,
ii. allocate block and room,
iii. Print function to display student’s regno, block name and room number. In main
method, create at least two structure variables and use those defined functions.
Provide sample input and expected output.
33. The National Earthquake Information centre characterizes the effect of earthquakes based
on Ritcher scale numbers. Design an algorithm and write a C code to print the
characterization given the Ritcher scale number.
Ritcher Scale Number Characterization
n<5.0 Little or no damage
5.0 <= n<5.5 Some damage
n>5.5 Serious damage
Check boundary conditions and print 'Invalid input' for wrong input.
34. There is a structure called employee that holds information like employee code, name,
date of joining. Write a C program to create an array of the structure and enter some data
into it. Then ask the user to enter current date. Display the names of those employees
whose tenure is 3 or more than 3 years according to the given current date.
35. Write a program to create a structure for customers in a bank with ( Account No, Name,
Balance Amount). Assume that there are N customers Write a function to print only those
customers whose name starts with 'A' and have balance greater than 10000.
36. A record contains the name of the cricketer, number of test matches played, average runs
scored each test match. create an array of structures for N cricketers and write functions
to read the details and print those players whose average is greater than the average
scores of all the players [ Make use of pointer to structures ]
38. Write a program to print palindrome numbers present between 100 and 500
Eg ( 101, 111,121,131…444)
39. Discuss all details about the parameter passing methods in C programming using a
sample program that helps to perform swapping operation. Add illustrations
wherever required.
Write a program to get the following output
1 ABCDEF
22 ABCDE
333 ABCD
4444 ABC
55555 AB
666666 A
40. Write a program to read two string and perform the following operations using pointers
1. swap two strings
2. concatenate the given two strings ( without using strcat function )
41. Little Bob loves chocolate, and he goes to a store with Rs. N in his pocket. The price of
each chocolate is Rs. C. The store offers a discount: for every M wrapper he gives to the
store, he gets one chocolate for free. This offer is available only once. How many
chocolates does Bob get to eat?
42. Given the number of hours and minutes browsed, write a program to calculate the bill for
Internet Browsing in a browsing center. The conditions are given below.
(a) 1 Hour Rs.50
(b) 1-minute Re. 1
(c) Rs. 200 for five hours
Boundary condition: The user can only browse for a maximum of 7 hours Check boundary
conditions
43. Write a C program that reads a person's DOB as a char array with the pattern "DD-MM-
YYYY" and calculates the sum of all the digits in the DOB.
44. Write a C++ program to define a base class Item (item-no, name, price). Derive a class
Discounted-Item (discount-percent). A customer purchases 'n' items. Display the item-wise bill
and total amount using appropriate format.
45. Consider two base classes worker (int code, char name, float salary),officer(float DA, HRA) class
manger(float TA(is 10% of salary), gross salary) is derived from both base classes. Write a C++
program to print the manager (Code, Name, Salary, DA, HRA, TA and Gross salary
[DA+HRA+TA+salary]) with necessary member function.
46. Write a Program to perform the following scenario. Define a class student with roll no as
member and getdata() and putdata() as member functions. Define another class test that
inherit the class student, this class test has data members as marks in the subject 1 and subject
2 with member functions getmark() and putmark(). Define a class Grade with data member
grade and a member function to display the grade. Define another class result that inherit the
classes test and Grade with data member total and member function to compute the total
marks along with the grade. Note make use of the access specifier Private for Grade class.
47. Create a bank customer class with the following data members name, account number,
account type, status (active/dormant), balance and last transaction date. Write a C++ program
to do the following:
(i) Display the name of the customer given the account number
(ii) Withdraw funds given the amount. Deny the withdrawal transaction if
balance becomes less than 1000.
(iii) Change the status of the account from active to dormant if no transactions
occurred in the past one year.
48. Write a C++ program to find the factorial of a number using copy constructor.
49. Create a C++ class for player object with the following attributes player no., name, number of
matches and number of goals done in each match. The number of matches varies for each
player. Write parameterized constructor which initializes player no., name, number of
subjects and creates array for number of goals and number of matches dynamically.
50. Suppose you have a Piggie Bank with an initial amount of $50 and you have to add some
more amount to it. Create a class 'AddAmount' with a data member named 'amount' with an
initial value of $50.
Now make two constructors of this class as follows:
1 - without any parameter - no amount will be added to the Piggie Bank
2 - having a parameter which is the amount that will be added to the Piggie Bank
Create an object of the 'AddAmount' class and display the final amount in the Piggie
Bank.
51. A boy has his money deposited $1000, $1500 and $2000 in banks-Bank A, Bank B and Bank
C respectively. We have to print the money deposited by him in a particular bank.
Create a class 'Bank' with a function 'getBalance' which returns 0. Make its three subclasses
named 'BankA', 'BankB' and 'BankC' with a function with the same name 'getBalance' which
returns the amount deposited in that particular bank. Call the function 'getBalance' by the
object of each of the three banks.
52. Create a class to represent a bank account with the following data members and member
functions
Data members :
Name, Accno, Type of Account (SB/CUR) and Balance
Member functions:
assign initial values ( make use of constructors )
deposit an amount - [D for deposit]
withdraw an amount [W- for withdrawal] after verifying the balance [ FOR SB a/c
balance > 1000 for Current A/c balance >5000]
display the name and balance
53. Create class employee with ENO, ENAME, EDEPT, SALARY and the member functions
ReadData(), PrintData(). your program to read N employee details using array of objects and
extract only those employees who are working in MARKETING and drawing salary less than
15000.
54. With the help of a single C++ program demonstrate the difference between staticdata
members, regular data members, static member functions, constant member functions and
regular member functions.
55. Write a structure to store the name, account number and balance of customers (more than 10)
and store their information.
a. To print the names of all the customers having balance less than $200.
b. To add $100 in the balance of all the customers having more than $1000 in their
balance and then print the incremented value of their balance.
56. Write a structure to store the roll no., name, age (between 11 to 14) and address of students
(more than 10). Store the information of the students.
a. Write a function to print the names of all the students having age 14.
b. Write another function to print the names of all the students having even roll no.
c. Write another function to display the details of the student whose roll no is given
(i.e. roll no. entered by the user).
57. Write a structure to store the names, salary and hours of work per day of 10 employees in a
company. Write a program to increase the salary depending on the number of hours of work
per day as follows and then print the name of all the employees along with their final salaries.
Hours of work per day 8 10 > =12
Increase in salary $50 $100 $150
58. Write a program to store and print the roll no., name , age and marks of 5 student using
structures.
59. Write a program to add, subtract and multiply two complex numbers using structures to
function.
60. Write a pointer and array notation to access a 2D pointer array int a[2][3] = {{1,2,3},{4,5,6}}.
61. Details of the members of a rotary club (Name, ClubID, Age, Date of joining , amount
collected, amount donated , Level -(Diamond/Gold/Silver), position -
(member/president/treasurer/secretary) are stored and maintained by the club authorities. On
the “Rotary club day” every two years, a new cabinet is appointed. The cabinet is made of
president, treasurer and secretary.
The rules for qualification are as follows:
A president should have already served as either secretary or treasurer and should
have collected/donated more than 1 lakh rupees and should be a diamond member.
A treasurer should have been an active member for more than 5 years and should
have collected/donated at least 50,000 rupees.
A secretary should be a silver member with at least 2 years of active membership.
Write a C program to list the names of the members who are qualified to be in the cabinet
this year using structures.
62. There is a structure called employee that holds information like employee code, name, date of
joining. Write a C program to create an array of the structure and enter some data into it.
Then ask the user to enter current date. Display the names of those employees whose tenure
is 3 or more than 3 years according to the given current date.
63. Write a program to create a structure for customers in a bank with ( Account No, Name,
Balance Amount). Assume that there are N customers Write a function to print only those
customers whose name starts with 'A' and have balance greater than 10000.
64. A record contains the name of the cricketer, number of test matches played, average runs
scored each test match. create an array of structures for N cricketers and write functions to
read the details and print those players whose average is greater than the average scores of all
the players [ Make use of pointer to structures ]
65. Illustrate the use of struct by creating a structure for student record with Regno, Name, Dept,
Date of birth for N students. The member date of birth should be a Union data type with Day,
month and year as attributes. Access the student record and print those who are born after 1st
January 2007. [ make use of Union within Structure concept ]
66. Write a 'C' program to accept customer details such as: Account_no, Name, Balance using
structure. Assume 3 customers in the bank. Write a function to print the account no. and
name of each customer whose balance < 100 Rs.
67. create two classes DM and DB. DM stores the distance in meters and centimetres and DB
Stores the distance in feet and inches. Write a program to read the values for the class objects
and Add one object DM with another object DB. Note: use a friend function to carry out
addition operation. The resultant object is stored in DM and display it.
1 feet = 30 centimetres
1 inch =2.54 centimetres
1 meter = 100 centimetres
68. Write a function using pointers to exchange values stored in two locations in the memory.
69. Write the calculator program to add, subtract, divide, and multiply using function pointer.
70. Write a 'C' Program to calculate sum of lower triangular elements of m X n matrix by using
dynamic memory allocation.
71. Write a C++ program to add two numbers using single inheritance. Accept these two numbers
from the user in base class and display the sum of these two numbers in derived class.
72. Write a C++ program to demonstrate how a common friend function can be used to exchange the
private values of two classes. (Use call by reference method).
73. Write a function in C to compare strings using pointer.