0
What is the o/p??plz explain
#include<stdio.h> void test_function(int ara[]) { ara[0]=100; return ; } int main() { int ara[] ={1,2,3,4,5}; test_function(ara); printf("%d\n",ara[0]); return 0; } Option:- A.1 B.100 C.1,2,3,4,5 D.4 (This que came in challenge task of sololearn..i have doubt abt this que's ans..my ans ws option b..n i hv checked in compiler when they said it was wrong...but when i compiled this code ,ans was option b...plz help me where i am wrong??)
6 Answers
+ 3
Eashan Morajkar
It will work. test_function has void as a return type which doens't return anything.
We have passed array in function as reference so whatever we change in that array then array's data will be change.
So here we have changed 1st value of array with 100.
So now array will be {100, 2, 3, 4, 5}
+ 1
Learner
ara[] is an array which is passed as a reference in function test_function where we have assigned 100 to 1st position of that array so now first value will be 100
That's why your output is 100
+ 1
Ohk ..i got it...thanx to both of u...
0
And anyways it shouldn't work because the test_function is returning nothing
0
Ok
- 1
it should be A.1