C Module Lab5 Cohort02 Functions
C Module Lab5 Cohort02 Functions
Lab # 05
FUNCTIONS AND WORKING WITH MULTIPLE FILES
2
Contents
Objective ............................................................................................................................... 4
Tools ..................................................................................................................................... 4
Lab Task # 01 : String Library................................................................................................ 4
Lab Task # 02........................................................................................................................ 5
Lab Task # 03........................................................................................................................ 5
Lab Task # 04........................................................................................................................ 5
Submission: .......................................................................................................................... 6
Lab # 05 www.ncdc.pk 3
Objective
The objective of this lab is to enable students to answer following questions:
• How to use functions?
• How to use multiple files in a project?
Tools
• GNU debugger
• GC compiler
Take an input sentence (maximum length N = 100) and perform the following
operations on the sentence using functions. Prepare string.h and string.cpp as library
files and use that library in main.
At the core of all scientific computations for nuclear simulation, weather modeling or
circuit simulation is linear algebra. In linear algebra, there are typically three levels of
operations that are the most common which usually involve arrays. You need to create
a linearalgebra.h and linearalgebra.cpp for this library.
Lab # 05 www.ncdc.pk 4
Lab Task # 02
Level 1 Operations - xTy
Write a function which takes inputs x and y from the user (x, y are vectors of size N).
Your program should then compute the dot product.
Lab Task # 03
Level 2 Operations - Matrix Vector Multiply (y=Ax)
Write a function which takes inputs A and x from the user (A is of size M x N, x is of
size Nx1) and compute the matrix vector multiplication. You should reuse dot
products in this function.
Flow Chart: 30 Minutes Code: 30 Minutes
Lab Task # 04
Level 3 Operations - Matrix Vector Multiply (C=AB)
Write a function which takes inputs A and B from the user (A is of size M x N, B is of
size NxK) and compute the matrix matrix multiplication. You should reuse dot
products in this function. You might have to take transpose of B.
Flow Chart: 30 Minutes Code: 30 Minutes
Lab # 05 www.ncdc.pk 5
Signal Processing Library
Lab Task # 05
Write a signal processing library to carry out the following functions. Your signal will
be an array of floats.
• Find average value of the signal
• Detect number of zero crossings in the signal
• Detect number of glitches in the signal
• Filtering of the signal with a given transfer function (size of signal and transfer
function will be fixed)
Lab # 05 www.ncdc.pk 6
H = [ 1 1 1 ; 1 1 1; 1 1 1]/9;
Submission:
Please submit .c and .h files of all the tasks along with the screenshots of outputs on
LMS in a proper report. Add snaps of all the flow charts in your report.
Lab # 05 www.ncdc.pk 7