#include <stdio.h>
int main(void)
{
long upper = -1, lower=0;
int reads;
do{
printf("Enter lower and upper integer limits (in that order): ");
reads = scanf("%ld%ld", &lower, &upper);
if (reads != 2){
while (getchar() != '/n') ; // if read fails, clear input buffer
}
} while (lower > upper); // if lower is greater than upper, get new input
printf("/n");
printf(" Integer | Square | Cube /n");
printf("---------------|---------------|---------------/n");
for (long int i = lower; i <= upper; i++)
{
printf(" %-14ld| %-14ld| %-14ld/n", i, i * i, i * i * i);
}
printf("/n");
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266550.html