I am just learning C. i am working through this problem trying to predict the output:
#include <stdio.h> int gNumber; int MultiplyIt( int myVar ); int main (int argc, const char * argv[]) { int i; gNumber = 2; for ( i = 1; i <= 2; i++ ) gNumber *= MultiplyIt( gNumber ); printf( "Final value is %d.\n", gNumber ); return 0; } int MultiplyIt( int myVar ) { return( myVar * gNumber ); } so if you run this, the output is 512. i am a bit confused on how the calculation is getting from the initial value of 2, then first time through the 'for' loop it then assigns gNumber = 8. then jumps to 512...
maybe i am missing something easy here, but as i said, i am very new to C and programing in general..
argcandargv. suggest changing the main function signature to:int main( void )