CSC373/406: Example: Pass by Value [5/8] Previous pageContentsNext page

file:square2.c [source]
00001: #include <stdio.h>
00002: // prototypes
00003: void square(int numb);
00004: int main()
00005: {
00006:   int val = 3;
00007:  
00008:   square(val);  
00009:  
00010:   printf("val = %d\n", val); // prints 3 (not 4)
00011:   
00012:   return 0;
00013: }
00014:  
00015: void square(int numb)
00016: {
00017:   int sq;
00018:  
00019:   numb++;            // 'numb' MODIFIED HERE to 4
00020:   sq = numb * numb;
00021:   printf("sq = %d\n", sq); // prints 16
00022: }
00023: 
00024: 

Previous pageContentsNext page