Thursday, July 9, 2009

Write a programme in C language(not in C++) to diffentiate between call by value and call by reference plz?

write a programme in C language(not in C++) to diffentiate between call by value and call by reference plzzzzzzzzzzzzzz


prog should be easy

Write a programme in C language(not in C++) to diffentiate between call by value and call by reference plz?
//this will help you understand the difference





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void increment1(int a)


{


a++;


}





void increment2(int *a)


{


(*a)++;


}





void main()


{


int a=1;


printf("Value of a = %d\n",a);


//call by value


increment1(a);


printf("Value of a = %d\n",a); //value of a remain same


//call by reference


increment2(%26amp;a);


printf("Value of a = %d\n",a); //value of a incremented


getch();


}
Reply:C Chink Cou Con't Cnderstand Chat C Cay!!!
Reply:I don't do homework for people.





Still, here's the clue.





In C, everything's really passed by value.


A pointer is a reference, so if you pass a pointer as a parameter, you're passing by reference.


If you pass a non-pointer variable, you're passing by value.
Reply:i have an exam today...i want answer for this too lol


No comments:

Post a Comment