PST Unit 3
PST Unit 3
PST Unit 3
4) What is an array? List two types of representation of 2-D array stored in memory.
Array is a bounded collection of elements of same data type.
Two-dimensional array are stored in the memory in the following two ways:
a) Row-Major representation:
Location[i,j]= Base Address(A) + {i*ColSize)+j}*WordSize
b) Column-Major representation:
Location[i,j]= Base Address(A) + {i*RowSize)+j}*WordSize
5) Write a C function to print random number between 0 to 49. Include header file.
C Function :
# include <stdlib.h>
for (i=0 ; i < 50 ; i++)
{
printf(“%d \n”, rand() % 50 );
}
12 6 10 11 16 (P) 28 24 29 26 25
<< <17 >> << 17> >>
A partitioned solution.