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

Cpplab

The document outlines 6 labs of programming exercises for an Object Oriented Programming course in C++. Lab 1 covers basic programs using variables, data types, loops. Lab 2 covers arrays and strings. Lab 3 covers classes, objects and encapsulation. Lab 4 covers inheritance, polymorphism and abstraction. Lab 5 covers file handling. Lab 6 covers exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Cpplab

The document outlines 6 labs of programming exercises for an Object Oriented Programming course in C++. Lab 1 covers basic programs using variables, data types, loops. Lab 2 covers arrays and strings. Lab 3 covers classes, objects and encapsulation. Lab 4 covers inheritance, polymorphism and abstraction. Lab 5 covers file handling. Lab 6 covers exception handling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming with C++ – LAB Programs

Lab-1: Basic programs in C++ (Topics: Variables, Datatypes, For loop and while loop)
1. Write a C++ program to swap two numbers?
2. Write a C++ program to check whether the give number is a palindrome or not?
3. Write a C++ program to display the fibanocci series?
4. Write a C++ program to print the pyramid triangle shape with stars and numbers range upto five
lines?
5. Write a C++ program to convert temperature in Celsius to Fahrenheit?
Topics: control structures and conditional statements
6. Write a C++ program to find the student grade based on the marks using switch case?
7. Write a C++ program to check whether the given number is prime number or not?
8. Write a C++ program to find the given number is even or not?
9. Write a C++ program to find vowels and consonants in a given word?
10. Write a C++ program to find largest among three numbers?
11. Write a C++ program to check whether it is a leap year or not?

Lab-2: Programming with arrays and strings (Topics: Arrays and Strings)
1. Write a C++ program to find sum and average of 10 numbers using arrays?
2. Write a C++ program to find largest and smallest element of an array?
3. Write a C++ program for two matrix addition?
Topic: Strings
4. Write a C++ program to find frequency of characters of strings?
5. Write a C++program to find number of vowels, consonants, digits and spaces in a given sentence?
6. Write a C++ program to remove all the characters except alphabets yin a given sentence (Ex: IDNO)?

Lab-3:Classes,objects and encapsulation


(Topics: Classes,Objects,Access specifiers,Encapsulation)
1. Write a C++ program to create a class for student to get and print details of a student (idno, name,
class and branch)?
2. Write a C++ program to create a class for student and display student details (id ,name,class,branch)
through method(insert,display)?
3. Write a C++ program to print addition of two numbers using default constructor and parameterized
constructor?
4. Write a C++ program to differentiate the public and private access specifiers consideringdata
members x,y as private an a,b as public and display the output?
5. 5.Write a C++ program implement the concept of encapsulation by considering data members(a,b)
as private and access through public methods as set and get?
Lab-4: Inheritance,Polymorphism and Abstraction
(Topics: Inheritance Types, Polymorphisim and Data Abstraction - Interfaces)
1 Write a C++ program to implement single inheritance using class names as student, mystudent and
display student details (id ,name ,batch, college name etc) .
2 Write a C++ program to implement multilevel inheritance using class names as grandparent, parent
and child; display the details of the family members?
3 Write a C++ program to implement multiple inheritance using class names as father, mother and
child; display the details of family members?
4 Write a C++ program to implement hierarchical inheritance using name student ,student1(name),
student2(name), and display the student1 and student2 respectively (id, name, branch, and marks of
each subject).
5 Write a C++ program to take subjects (NT, OOPS,EDC) as class names , attributes as MID-1, MID-!!
and ENDSEM marks of each subject ,use the method name as totalmarks(). Display the student
marks subject wise with (id,name ,branch,and marks of each subject)
6 Write a C++ program to explain two types of polymorphism (run time – compile time) with an
example?

Lab-5: File handling (File handling and streams, Read and Write operations)
1. Write a C++ program to read input from user and Write into output file?
2. Write a C++ program to read data from input file and Write it into output file?
3. Write a C++ program reading data from user and append the data into output file?

Lab-6: Exception handling (Exception handling and user defined exception)


1. Write a C++ program to handle arthemetic exception using try catch method?
2. Write a C++ program to explain user defied exception?
3. Write a C++ program for implicit conversion (int, float , character ) with example?
4. Write a program to explain static cast operator with an example?

You might also like