hello,
I have problem with a function declaration, in following program the main section initializes k to 0. The function f is known as k <4. As increments each time, this function will be performed 4 times. My only problem is that I have a printf ( "% ld", i) at the beginning of the loop and the PC gives me the value 0 so the loop should never execute (j <= i)!. Yet it runs 4 times.
Code:# include <stdio.h> # include <stdlib.h> float f (int i) ( int j = 1, k = 1; while (j <= i) ( k = k * j; j + +; ) return k; ) int main (int argc, char * argv) (Int i; int k = 0; do ( printf ( "f (% i) =% f \ n", k, f (k)); k + +; ) while (k <4); system ( "PAUSE"); return 0; )


Reply With Quote

Bookmarks