C examples for Statement:for
Use for loop only to control the console number reading logic
#include <stdio.h> int sqrnum(int num); int readnum(void); int prompt(void); int main(void) { int t;/*from w w w . ja v a 2s. co m*/ for (prompt(); t = readnum(); prompt()) sqrnum(t); return 0; } int prompt(void) { printf("Enter a number: "); return 0; } int readnum(void) { int t; scanf("%d", &t); return t; } int sqrnum(int num) { printf("%d\n", num*num); return num*num; }