C - Functions - Discussion

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

 



Q.

#include

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=b;
b=temp;
}

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

Answer: Option A
Explaination:

Pass by value: In this approach we pass copy of actual variables in function as a parameter. Hence any modification on parameters inside the function will not reflect in the actual variable.



Discussion

Your Comments Goes here...
NameDiscussion