版权声明:转载请附上文章地址 https://blog.csdn.net/weixin_38134491/article/details/86538580
Probelm:
Write a program that inputs a series of 5 numbers and determines and prints the largest of the numbers,
Use ‘do-while’ statement
#include<stdio.h>
#include<stdlib.h>
int main(void) {
int num;
int max;
int i=0;
do {
printf("Enter the number:");
scanf_s("%d", &num);
if (i == 0) {
max = num;
}
else {
if (num > max) {
max = num;
}
}
i = i + 1;
} while (i < 5);
printf("Largest is %d\n", max);
system("pause");
return 0;
}