我正在自己在线学习C编程,这样我就可以为2016年冬天的大学做好准备.我正在学习数据类型.我不明白之间的区别:
short
long
long long integers in C programming
Run Code Online (Sandbox Code Playgroud)
我在线查看,但我仍然对如何使用这些以及何时使用感到困惑.谢谢.
我正在编写一个C程序来重复一系列指定时间的问题.我要求用户输入他们想要的尝试次数,然后我根据他们的数量运行以下循环,但问题是循环不断重复.它不会停止在指定的尝试次数.这是代码:
#include <stdio.h>
int main(void){
int num1,num2,high,low,average,subtotal,total_aver;
printf("Enter number of tries you want:");
scanf("%d", &num1);
while (num1 < num1 + 1) {
printf("Try number: ");
scanf("%d", &num2);
printf("Enter high ");
scanf("%d", &high);
printf("Enter low ");
scanf("%d", &low);
subtotal = high + low;
total_aver = subtotal / 2;
printf("Average temperature is: %d", total_aver);
}
}
Run Code Online (Sandbox Code Playgroud)
如果用户输入3尝试次数,那么程序应该在循环内部询问这些问题三次,但它会不断重复而不会结束.