Question on example of C Functions and Data Types
Four of the basic data types 'int', 'float', 'double' and 'char' were already presented in the Data Types lesson of the Basic Concepts section. Other variants of the 'int' data type are 'long int' and 'long long int', which apparently have vastly expanding numeric ranges than does 'int' itself. My question is on the unexpected results from adjusting the sample program in the Functions in C lesson to calculate cubes instead of squares, as follows: ------ code ------ #include <stdio.h> /* declaration */ long int cubed (int num); long int main() { int x; long int result; x = 1400; result = cubed(x); printf("%d to the third power is %d\n", x, result); return 0; } /* definition */ long int cubed (int num) { long int y; y = num * num * num; return(y); } ------------------ Why do the results of this code always give 1400 to the third power as -1550967296 regardless of whether 'long int', 'long long int', or basic 'int' are substituted into the corresponding declaration, main()-block, and definition sections just as above?? What further #include header, conversion keywords, and/or other additions should I use to get the expected results in the above cubed function and its main() call??