C - Functions - Discussion

You Are Here :: Home > C > Functions - Discussion

 



Q.

#incude

int main(){
int a=5,b=10;
swap(&a,&b);
printf("%d %d",a,b);
return 0;
}
void swap(int *a,int *b){
int *temp;
*temp =*a;

A. 5 10 B. 10 5
C. 5 5 D. 10 10

Answer: Option B
Explaination:

Pass by reference: In this approach we pass memory address actual variables in function as a parameter. Hence any modification on parameters inside the function will reflect in the actual variable.



Discussion

Your Comments Goes here...
NameDiscussion