# Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 81 - 82 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 81

C & C Plus Plus
Edit

### Describe in Detail

Essay▾
1. `#include<studio.h>`
2. `main ()`
3. `{`
4. `    int a[2][2][2] ={ { 1, 2, 3, 4}, { 5, 6, 7, 8} };`
5. `    int ⚹p, ⚹q;`
6. `    p =&a[2][2][2];`
7. `    ⚹q =⚹ ⚹⚹ a;`
8. `    printf ( “%d____%d” ⚹p, ⚹q);`
9. `}`

### Explanation

In a program

 a [2] [2] [2] = { {1,2, 3,4} , {5,6, 7,8} } ; Define the array and it՚s value int ⚹ p, ⚹ q; Define the 2 integer pointer p and q p = &a [2] [2] [2] ; You declared only 2D array, but you are trying to access 3D array so, it will print garbage value. ⚹ q =⚹ ⚹⚹ a; Starting address of aIf you print ⚹ q , it will print first element of 3D array (or our 2D array starting address remains the same) printf ( “% d________ % d” ⚹ p, ⚹ q) ; So, the print is SomeGarbageValue________1

## Question 82

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

What is the output of the following program?

1. `unc (a, b)`
2. `int a, b;`
3. `{`
4. `    return (a =(a == b) );`
5. `}`
6. `main ()`
7. `{`
8. `    int process (), func ();`
9. `    printf ( “The value of process is %d! ” process (func, 3, 6) );`
10. `}`
11. `process (pf, val1, val2)`
12. `int ( ⚹pf) ();`
13. `int val1, val2;`
14. `{`
15. `    return ( ( ⚹pf) (val1, val2) );`
16. `}`

### Explanation

The value of process is 0!

In the program

 main (){int process () , func () ;printf ( “The value of process is % d!” process (func, 3,6) ) ;} main () invokes 2 functionsint process () and int func () process (pf, val1, val2)int (⚹ pf) () ;int val1, val2;{return ( (⚹ pf) (val1, val2) ) ;} The function ‘process’ has 3 parameters.1st is pointer to another function , 2 and 3 integers.When this function is invoked from main, the following substitutions for formal parameters take place: func for pf, 3 for val1 and 6 for val2.This function returns the results of the operation performed by the function ‘func’ . func (a, b)int a, b;{return (a = (a == b) ) ;} The function func has two integer parameters.The formal parameters are substituted as 3 for ‘a’ and 6 for ‘b’ .Since 3 is not equal to 6, a == b returns 0.Therefore, the function returns 0 which in turn is returned by the function ‘process’ .

Developed by: