首先,你正在使用
n
作为您的
while
循环将在第一次交互时退出。使用您的
i
变量,并在每次执行循环时增加它。
do{
...
}while(i <= 5);
printf("enter the number %d:\n", i); //do not increment it here!
scanf("%d",&n); //assuming "n" as your variable to scan
if(n > 0 && n < 11){
add += n;
i++; //increment it here instead!
}