735 views
0 votes
0 votes
#include<stdio.h>
int fun(int arr[])
{
    arr=arr+1;
    printf("%d",arr[0]);
}
int main(void){
    int arr[2]={10,20};
    fun(arr);
    printf("%d",arr[0]);
    return 0;
}

A.COMPILE ERROR   B.20,10

C.10,20       D.20,20

1 Answer

0 votes
0 votes
int fun(int arr[])   // arr will point to first element of the array
{
    arr=arr+1; // now arr will point to next element  
    printf("%d",arr[0]); // Second element is 20 & it will print
}
int main(void){
    int arr[2]={10,20};
    fun(arr);
    printf("%d",arr[0]); // first element is 10 ,So it will print that value.
    return 0;
}

Related questions

0 votes
0 votes
1 answer
1
Balaji Jegan asked Nov 15, 2018
1,332 views
Predict the Output for both the snippets for the following:1. Call by Value2. Call by Reference3. Call by Need4. Call by Name5. Call by value Result/Call by value Return(...
0 votes
0 votes
0 answers
2
Rahul_Rathod_ asked Oct 3, 2018
530 views
from below list of parameter passing techniques, which parameter passing technique we can implement in c?1) call by value2) call by refference3) call by value result4) ca...
0 votes
0 votes
0 answers
3
Hira Thakur asked Sep 13, 2018
307 views
why we use parameter passing technique in C??ORpurpose of using "parameter passing technique"??ORwhat is the advantage of using it in C??
0 votes
0 votes
0 answers
4
Rishabh Baghel asked Mar 5, 2018
574 views
Does C support all passing parameters techniques like call by text, call by copy restore, and call by name?