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

Data Strcuture Lab - 01 AIUB

This document outlines the topics and objectives of a lecture on basic programming with loops, arrays, and functions. The lecture will cover writing code to solve problems using these concepts, including initializing and printing arrays, counting even and odd numbers, writing functions to print ranges and calculate factorials, and performing matrix addition. Recommended books and online references are also provided.

Uploaded by

mahin ramchagol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

Data Strcuture Lab - 01 AIUB

This document outlines the topics and objectives of a lecture on basic programming with loops, arrays, and functions. The lecture will cover writing code to solve problems using these concepts, including initializing and printing arrays, counting even and odd numbers, writing functions to print ranges and calculate factorials, and performing matrix addition. Recommended books and online references are also provided.

Uploaded by

mahin ramchagol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Basic Programming on

Loops, Arrays, and Functions


Course Code: CSC 2107 Course Title: Data Structure (Lab)

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 1 Week No: 1 Semester:


Lecturer: Name & email
Lecture Outline

1. Rules & Guidelines


2. Lab Tasks
3. Prerequisites
4. Objectives
5. Problem Descriptions
6. Books
7. References
Rules & Guidelines

Write your own rules to evaluate lab tasks.​


Lab Tasks

1. Write C++ code to solve all the problems starting from slide 7 to 11.

2. Any remaining problem unsolved will be home task.


Prerequisites

 Have a basic understanding of Loops, Arrays, and Functions.


Objectives

 To know how to solve basic programming problems with Loops, Arrays, and
Functions.

 To know basic relationship between the usage of Loops and Arrays.

 To know basic structure of a function and its usage.


Problem Descriptions
Problem 1

1. Initialize an array of 10 elements and print the array elements both in normal and
reverse order.

For example,
Input: 12 32 43 1 54 53 15 64 3 13

Output: 13 3 64 15 53 54 1 43 32 12
Problem Descriptions
Problem 2

2. Initialize an integer array of 10 elements and print how many numbers are odd and
how many numbers are even.

For example,
Input: 12 32 43 1 54 53 15 64 3 13

Output:
6 odd numbers
4 even numbers
Problem Descriptions
Problem 3

3. Write a function that takes TWO parameters to print all the odd numbers between
a given range. Input the starting value of the range and ending value of the range.
Then, send them as the parameters to your function.

For example,
Output:
Starting value: 12
Ending value: 23

13 15 17 19 21 23
Problem Descriptions
Problem 4

4. Write a program to perform matrix addition between 3 matrices.

For example,
Input:
12 13 14 1 2 3 101 104 107
15 16 17 4 5 6 102 105 108
18 19 20 7 8 9 103 106 109

Output:
114 119 124
121 126 131
128 133 138
Problem Descriptions
Problem 5

5. Write a function to calculate factorial of a given integer number if that number is a


prime number. If it is not, it will give an error.

For example,
Scenario 1
Input: 5
Output: 120

Scenario 2
Input: 4
Output: Error! Not a prime number.
Books

 “Schaum's Outline of Data Structures with C++”. By John R. Hubbard


 “Data Structures and Program Design”, Robert L. Kruse, 3rd Edition, 1996.
 “Data structures, algorithms and performance”, D. Wood, Addison-Wesley, 1993
 “Advanced Data Structures”, Peter Brass, Cambridge University Press, 2008
 “Data Structures and Algorithm Analysis”, Edition 3.2 (C++ Version), Clifford A.
Shaffer, Virginia Tech, Blacksburg, VA 24061 January 2, 2012
 “C++ Data Structures”, Nell Dale and David Teague, Jones and Bartlett Publishers,
2001.
 “Data Structures and Algorithms with Object-Oriented Design Patterns in C++”,
Bruno R. Preiss,
References
1. https://en.wikipedia.org/wiki/LOOP_(programming_language)
2. https://en.wikipedia.org/wiki/Array_data_structure
3. https://www.programiz.com/cpp-programming/function

You might also like