C examples for Data Type:int
Prints a table giving an integer using a for loop, its square, and its cube. Ask the user to input the lower and upper limits for the table.
#include <stdio.h> int main( void ) { // w ww .jav a2 s . c om int lower, upper, index; int square, cube; printf("Enter starting integer: "); scanf("%d", &lower); printf("Enter ending integer: "); scanf("%d", &upper); printf("%5s %10s %15s\n", "num", "square", "cube"); for (index = lower; index <= upper; index++) { square = index * index; cube = index * square; printf("%5d %10d %15d\n", index, square, cube); } return 0; }