CS210 DSA Lab 01 000
CS210 DSA Lab 01 000
LAB NO. 01
POINTERS, ONE DIMENSION (1-D) ARRAY
& STRUCTURES
Following are the lab objectives:
1. Refresh concept of pointers
Objectives
Lab
Student
ID Student Name
Obtained
Marks Comments
Marks
Task 1 10
Task 2 10
Task 3 10
Task 4 10
Task 5 15
Total
55
Marks
Lab Instructor
Date: 13-09-2019
1
CS 210 – Data Structures and Algorithms Lab Manual
CLOs
Lab Objectives
a b c
1
2
3
4
Instructions
This is individual Lab work/task.
Complete this lab work within lab timing.
Discussion with peers is not allowed.
You can consult any book, notes & Internet.
Copy paste from Internet will give you negative marks.
Lab work is divided into small tasks, complete all tasks sequentially.
Show solution of each lab task to your Lab Instructor.
In-Lab Exercises/Tasks
Write your code at provided space after each question
You need to upload code for all tasks at Google Class.
2
CS 210 – Data Structures and Algorithms Lab Manual
LAB TASKS
Task 1 (10 mark)
Part A
Write a C++ program that declares and initializes (to any value you like) a double, an int, and a
string. Later on declare three pointers which can store the addresses of respective variables.
Program should then print the address of, and value stored in, each of the variables using pointer
dereference concept.
Part B
Draw a small memory map showing the location of each of the variables and pointers in your
program.
3
CS 210 – Data Structures and Algorithms Lab Manual
4
CS 210 – Data Structures and Algorithms Lab Manual
Write a program to input five integers in an array and display the values in ascending and
descending order, using a pointer.
5
CS 210 – Data Structures and Algorithms Lab Manual
Write a program in C++ that stores the area of 3 rooms, using Structure namely "distance". Take
input of feet & inches from user for variable d1 (feet & inches), assign variable d2 = {10, 5.25}
values. Now add feet and inches of d1 & d2 and store ind3.
Display d1 (feet & inches), d2 (feet & inches) & d3 (feet & inches) separately. Put Condition if
d1 & d2 inches increase by 12 it become a foot.
6
CS 210 – Data Structures and Algorithms Lab Manual
int id,
string name
float salary .
Ask the user to fill in data for three employees and then display information for each employee.
7
CS 210 – Data Structures and Algorithms Lab Manual
Create a structure of type date that contains three members: the month, the day of the month, and
the year, all of type int. (Or use day-month-year order if you prefer.) Have the user enter a date in
the format 12/31/2001, store it in a variable of type struct date, then retrieve the values from the
variable and print them out in the same format.
Create two arrays (static and dynamic) and perform input / output operations.
8
CS 210 – Data Structures and Algorithms Lab Manual
9
CS 210 – Data Structures and Algorithms Lab Manual
EXTRA TASKS
Task 1
Create a structure called time. Its three members, all type int, should be called hours, minutes,
and seconds. Write a program that prompts the user to enter a time value in hours, minutes, and
seconds. This can be in 12:59:59 format, or each number can be entered at a separate prompt
(“Enter hours:”, and so forth). The program should then store the time in a variable of type struct
time. Perform addition and subtract of time on two object of type time.
10