Hi All,
I was wondering if someone could help me out with the following code. I am just learning C and am trying to compile the following program but keep running into errors regarding the initialization of 'x' and 'y' even though I initialized them in the beginning. Can someone offer assistance? Thank you. Here's the code followed by the errors:
insertThese are the errors I'm getting:Code:#include <stdio.h> main() { int x,y; float f,z; char c = 'A'; double d; /** Let us initialize some variables * / x = 5; y = 10.0; z = 7.5; f = 105.10; if(y = 10) /*if y equals 10 */ x += 20; /*add 20 to x */ z = y + x; /*** ***/ f = z*z*z; /* raise z to the third power*/ f = z/15; d = z*f; // yet another product y = (int)z; // cast z into an integer c = c - 32; /*convert character into lower character */ printf("x = %d, y = %d, z = %-5d\n",x,y,z); printf("f = %d \t %x \t %8.4f\n",f,f,f); printf("d = %i\n", d); printf("c = %c \t %x \t %o\n",c,c,c); printf("d = %i\n", d); return 0; }
(18) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
(16) : warning C4700: uninitialized local variable 'x' used
(18) : warning C4700: uninitialized local variable 'y' used