Академический Документы
Профессиональный Документы
Культура Документы
C++
Lab Assignments
1
C++ Lab Assignment
Lecture No. 1
Assignment No. 1
Objective
Command to be Used
1. Cout<<
Output:
2
C++ Lab Assignment
Lecture No- 2
Assignment No- 1
Objective
Write a program to get a string from the User by declaring variable and Display it.
Command to be Used
1. Cin>>
2. Cout<<
3. Declaring Variable.
Output:
3
C++ Lab Assignment
Lecture No. 2
Assignment No. 2
Objective
Write a program to get Rollo, Name, and Marks from the User, Calculate total marks and Display
it.
Command to be Used
1. Declaring Variable.
2. Understanding Data Type
3. Understanding Arithmetic Operator.
Output:
4
C++ Lab Assignment
Lecture No. 3
Assignment No. 1
Objective
Write a program that To Accept Mark from the User and Display
If Marks>=90 Display grade ‘A’
Marks >= 80 Display grade ‘B’
Marks >= 70 Display grade ‘C’
Marks >= 60 Display grade ‘D’
Else grade ‘F’
Command to be used
1. Nested if else
Output
5
C++ Lab Assignment
Lecture No- 3
Assignment No- 2
Objective:
Command to be Used
1. For…Loop
Output:
6
C++ Lab Assignment
Lecture No- 3
Assignment No- 3
Objective:
Command to be Used
1. Nested For…Loop
Output:
7
C++ Lab Assignment
Lecture No. 3
Assignment No. 4
Objective
Commands to be used
1. switch case
Output
8
C++ Lab Assignment
Lecture No. 3
Assignment No. 5
Objective
Write a program to calculate the sum of numbers entered, accept the number for addition as
many as user enters using while loop.
Command to be used
1. While loop
Output
9
C++ Lab Assignment
Lecture No- 4
Assignment No- 1
Objective
Command to be used
1. Multidimensional Array.
2. For Loop.
Output
10
C++ Lab Assignment
Lecture No- 4
Assignment No- 2
Objective
Write a program, Assign 5 products id, product name using Single Dimensional Array
Finally Display the Id, Product name as per given format.
Command to be used
1. For loop
2. Single Dimensional Array
3. Double Dimensional Array
Output:
11
C++ Lab Assignment
Lecture No- 5
Assignment No- 1
Objective
Write a program to store a date using structure. Define date, month, year, day as elements of the
structure Date
Commands to be used
1. Structures
Output
12
C++ Lab Assignment
Lecture No- 5
Assignment No- 2
Objective
Enter and then store the Student name, Address, Phone no and id using structure and array.
Commands to be used
1. Structures
Output
13
C++ Lab Assignment
Lecture No- 6
Assignment No- 1
Objective
Write a program to accept a string and check whether it is same as reverse or not e.g. Malayalam
using string functions
Commands to be used
1. String functions
Output
14
C++ Lab Assignment
Lecture No- 6
Assignment No- 2
Objective
Commands to be used
1. Math functions
Output
15
C++ Lab Assignment
Lecture No- 7
Assignment No- 1
Objective
Commands to be used
1. Functions
Output
16
C++ Lab Assignment
Lecture No- 7
Assignment No- 2
Objective
Commands to be used
1. Functions
Output
17
C++ Lab Assignment
Lecture No- 8
Assignment No- 1
Objective
Write a program As a Class of Products with data members productid, productName, price ,
quantity and member function to display the product details & billing;
Commands to be used
1. Class
2. Data members
3. Member functions
Output:
18
C++ Lab Assignment
Lecture No- 8
Assignment No- 2
Objective
Define a class Date having methods, getDate() to display date, putDate() to set value and
dateDifference() to calculate difference between dates.
(Hint: convert month & year into days)
Commands to be used
1. Class
2. Data members
3. Member function
19
C++ Lab Assignment
Lecture No- 9
Assignment No- 1
Objective
Write a program to define a class matrix of size 2x3 and find sum of it using friend function.
Commands to be used
1. Array
2. For loop
3. Friend function
Output:
20
C++ Lab Assignment
Lecture No- 9
Assignment No- 2
Objective
Write a program to define a class matrix of size 2x3 and create a pointer to object of the class to
display the matrix
Commands to be used
1. Pointer
Output:
21
C++ Lab Assignment
Lecture No-10
Assignment No- 1
Objective
Write a program to define a class address with constructor accepting the address details, then
create objects of it obj1 and copy the object into obj2 using copy constructor
Commands to be used
1. Class
2. Copy constructor
Output:
22
C++ Lab Assignment
Lecture No- 10
Assignment No- 2
Objective:
Create a Shape class having constructor to initialize triangle with parameter length, height and
equilateral triangle with length as parameters using constructor overloading. And display the area
of triangle
(Hint: use pythourus theorem to calculate the height in equilateral triangle)
Command to be Used
1. Constructor Overloading
Output:
23
C++ Lab Assignment
Lecture No- 11
Assignment No- 1
Objective:
Command to be used
1. Inline Function
Output:
24
C++ Lab Assignment
Lecture No- 11
Assignment No- 2
Objective:
Create a function to calculate service tax using inline function and define a class MyClass having
Data member x, get_x(), set_x(int) as methods and then create array of objects and find its
service tax
Command to be used
1. Inline Function
Output:
25
C++ Lab Assignment
Lecture No- 12
Assignment No- 1
Objective:
Write a program for overloading + operator to find addition two time values
Command to be Used
1. Operator Overloading
Output:
26
C++ Lab Assignment
Lecture No- 12
Assignment No- 2
Objective:
Write a program for overloading * operator to find product of two complex numbers
2
(hint: declare three variable for real, imaginary , square. For display x print (char)178.)
Command to be Used
1. Operator Overloading
Output:
27
C++ Lab Assignment
Lecture No- 13
Assignment No- 1
Objective
Define a class Person and derived class Employee. In Person class create properties Name,
Address, Tel, DateOfBirth and In Employee class declare properties EmployeeID, DateofJoin,
Salary, Department, Designation.
Commands to be used
1. Inheritance
28
C++ Lab Assignment
Lecture No- 13
Assignment No- 2
Objective
From the previous assignment make a derived class Manager from Employee having properties
NumberOfBranchesHandling, NoOfStaffHandling. Call the constructor of base class in derived
class to pass parameters.
Commands to be used
1. Inheritance
Output
29
C++ Lab Assignment
Lecture No- 14
Assignment No- 1
Objective
Create minus method as a global pointer to a function that has two parameters of type int, it is
immediately assigned to point to the function subtraction, all in a single line:
Commands to be used
1. Virtual function
2. Pointer
Output
30
C++ Lab Assignment
Lecture No-15
Assignment No- 1
Objective
Commands to be used
1. Manipulators
Output
31
C++ Lab Assignment
Lecture No- 16
Assignment No- 1
Objective
Write a program to store the details car parts using linked list
Commands to be used
1. Linked list
Output
32
C++ Lab Assignment
Lecture No- 17
Assignment No- 1
Objective
Write a program to save details of car parts in previous assignments using linked list in file and
display it from file
Commands to be used
1. ifstream
2. ofstream
Output
33
C++ Lab Assignment
Lecture No- 18
Assignment No- 1
Objective
Commands to be used
1. Templates
Output
34