Posts

Showing posts from October, 2013

Pointers - 3.2 PARAMETER PASSING USING POINTERS

Image
4.2 PARAMETER PASSING USING POINTERS What do you understand by parameter passing? It is important when you use functions. How does parameter passing relate to pointers? Pointers are normally passed to functions. This way, we pass the address to a local variable that points to the actual location of the data item by the calling program. The value that is changed in the function will change the value at the actual location. This method of passing is known as passing by reference or  reference passing. Program 4.1 #include #include  #include #include float calculateTotal1(int, int, int, float); float calculateTotal2(int, int, int *, float *); int main(){ int total1, total2, i, total; float average1, average2, average;                  total1 = total2 = 0;               average1 = average2 = 0.0;  for (i=1;i<=9;i++) total +=1; average = (float) total /8; printf(" %d %....