Yahya Buharali - 202211003
1. Compare by a method example between pass-by-value and pass-by-references ?
Pass-by-value
sends a copy of the contents of the actual parameter
So, the actual parameter cannot be changed by the function.
#include <iostream.h>
void Fun(int a);
int main(){
the value of the x stays the same in the
int x = 5; main function which is 5
Fun(x);
cout << x;
return 0;
void Fun(int a){
a = a * 2;
and here after the calculation, x
} equals to 10
Pass-by-reference
sends the location (memory address) of the actual parameter
So, can change value of actual parameter
#include <iostream.h>
void Fun(int &a);
the value of the x can be changed by
int main(){ the calling function using the and sign
int x = 5;
Fun(x);
cout << x;
return 0;
void Fun(int &a){
a = a * 2;
}
2. To which the struct belongs to: built in composite data type.
2.1 Address
2.2 Simple
2.3 Composite
3. Complete the following ( given; base address= 20, integer size=2, column size =6)
3.1 The virtual address of a[3] is 32
A[3] = base address + index * size
= 20 + 3 * 4
= 20 + 12
= 32
3.2 The virtual address of a[3][2] is not found.