Unit II
Unit II
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.
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.
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.
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.
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.
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.