C Programming Lab.... Arrays and Pointers
C Programming Lab.... Arrays and Pointers
except that a separate pair of square brackets is required for each subscript. We can use multidimensional arrays to perform operations on matrices. Pointers are variables which contain the addresses of data items i.e they point to the data item to be accessed. Pointers find extensive use in passing arguments to functions, as well as when working with ragged arrays. In this lab we will make use of multi-dimensional arrays and pointers in our programs. .
INSTRUCTIONS 1. There are 2 programs to be compiled and executed during this lab session. After each program you are required to show your supervisor the program output during the lab session. 2. The Exercises section of this lab manual contains a programming question for you to work on during the week. Submit these on or before the next lab session. (Save the program and give it to your class rep for submission). Save your program in the following format: <reg no_lab number> For example: H1025468V_lab7
Program 1 Adding two matrices Compile and run the following program:
Program 2 Write a program in C which finds the determinant of a 3x3 matrix. The user should input the matrix elements and the program should store them in a multi-dimensional array.
Exercise Using pointer notation, write a program in C which reads in five names from the user, and arranges them in alphabetical order.