اكتب برنامج C يقبل بعض الأعداد الصحيحة من المستخدم ويجد أعلى قيمة وموضع الإدخال
- برمجة
- برمجة سي c
- 2021-05-01
- Wassim
الأجوبة
/*Write a C program that accepts some integers from the user and find the highest value and the input position*/
#include
#define MAX 5
int main()
{
int number[MAX], i, j, max=0, num_pos=0;
printf("Input 5 integers: \n");
for(i = 0; i < MAX; i++) {
scanf(" %d", &number[i]);
}
for(j = 0; j < MAX; j++)
{
if(number[j] > max) {
max = number[j];
num_pos = j;
}
}
printf("Highest value: %d\nPosition: %d\n", max, num_pos+1);
return 0;
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال