📄 total5f.c
字号:
/*-*//******************************************************** * Program: ADD5 -- Adds up 5 numbers. * * * * Usage: * * Run it, type in 5 numbers and get a total. * * * * Note: This is the same as program 8.1 except it * * uses a for loop instead of a while. * ********************************************************//*+*/#include <stdio.h>int total; /* total of all the numbers */int current; /* current value from the user */int counter; /* for loop counter */char line[80]; /* Input from keyboard */int main() { total = 0; for (counter = 0; counter < 5; ++counter) { printf("Number? "); fgets(line, sizeof(line), stdin); sscanf(line, "%d", ¤t); total += current; } printf("The grand total is %d\n", total); return (0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -