C语言基础:for循环演示代码,字符循环和浮点数循环
#include <stdio.h> int main () { char letter; float percent; for (letter = 'A'; letter <= 'Z'; letter++) putchar(letter); for (letter = 'z'; letter >= 'a'; letter--) putchar(letter); putchar('\n'); for (percent = 0.0; percent < 1.0; percent += 0.1) printf("%3.1f\n", percent); return 1; }
gcc编译运行结果
ABCDEFGHIJKLMNOPQRSTUVWXYZzyxwvutsrqponmlkjihgfedcba 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9