0% found this document useful (0 votes)
38 views

Unit II

The document contains 30 questions related to C++ programming concepts like structures, classes, objects, constructors, destructors, static members, friend functions, parameterized constructors, default arguments, arrays of structures and classes. Some questions ask to write programs to declare structures and classes with given data members, accept and display data. Other questions ask about properties, uses and examples related to static data members, friend functions, constructors, destructors and parameterized constructors.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Unit II

The document contains 30 questions related to C++ programming concepts like structures, classes, objects, constructors, destructors, static members, friend functions, parameterized constructors, default arguments, arrays of structures and classes. Some questions ask to write programs to declare structures and classes with given data members, accept and display data. Other questions ask about properties, uses and examples related to static data members, friend functions, constructors, destructors and parameterized constructors.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1) Write a C++ program to declare a structure employee with members as empid and

empname. Accept and display data for one employee using structure variable.

2) Write a C++ program to declare a structure book with members as book id and name.

3) Accept and display data of five books using array of structure.

4) Write a program to declare a class ‘student’ having data members as ‘stud_name’ and
‘roll_no’. Accept and display this data for 5 students.

5) Write a C++ program to declare a class ‘circle’ with data members as radius and area.
Declare a function getdata to accept radius and putdata to calculate and display area of
circle.

6) Write a C++ program to create a class STUDENT The data members of STUDENT
class.
Roll_No
Name
Marks
Accept data for five students and display it.

7) Write a C++ program to declare a class mobile having data members as price and model number.
Accept and display the data for Ten objects.

8) Write a C++ program to declare a class ‘Account’ with data members as accno, name and bal.
Accept data for eight accounts and display details of accounts having balance less than 10,000.

9) Describe use of static data member.

10) Write two properties of static member function.

11) Describe use of static data member in C++ with example.

12) Write any two characteristics of static data member. Write C++ program to count number of
objects created with the help of static data member.

13) Write any two characteristics of friend function.

14) Explain the friend function with proper example.

15) Write a C++ program to declare two classes with data members as m1 and m2 respectively. Use
friend function to calculate average of two (m1, m2) marks and display it. (Hint : class 1
contains m1 and class 2 contains m2)

16) Write a C++ program to find greatest number among two numbers from two different classes
using friend function.

17) Write a C++ program to find smallest number from two numbers using friend function. (Hint :
use two classes).
18) Define class and object.

19) Describe how memory is allocated to objects of class with suitable diagram.

20) Differentiate between contractor and destructor.

21) State the rules for writing destructor function.

22) What is parameterized constructor?

23) Write a C++ program to declare a class student with datamembers as roll no and name. Declare a
constructor to initialize data members of class. Display the data.

24) Write a C++ program to declare a class student with members as roll no, name and department.
Declare a parameterised constructor with default value for department as ‘CO’ to initialize
members of object. Initialize and display data for two students.

25) Describe constructor with default arguments with an example.

26) Write any two characteristics of destructor.

27) Write a C++ program to declare a class ‘circle’ with data members as radius and area. Declare a
function getdata to accept radius and putdata to calculate and display area of circle.

28) Write a C++ program to declare a class addition with data members as x and y. Initialize value of
x and y with constructor. Calculate addition and display it using function ‘display.’

29) Write a C++ program to declare a class ‘Account’ with data members as accno, name and bal.
Accept data for eight accounts and display details of accounts having balance less than 10,000.

30) Give output for following code:


class student
{
int roll no;
char name [14];
} s[6];
void main( )
{
cout <<sizeof(s);
}

You might also like