اكتب برنامج C لحساب متوسط علامات الرياضيات لبعض الطلاب. أدخل 0 أو قيمة سالبة لإنهاء عملية الإدخال
- برمجة
- برمجة سي c
- 2021-05-01
- Wassim
الأجوبة
/*Write a C program to calculate the average marks of mathematics of some students. Input 0 (excluding to calculate the average) or negative value to terminate the input process*/
#include <stdio.h>
int main()
{
int marks[99], m, i, a=0, total=0;
float f;
printf("Input Mathematics marks (0 to terminate): ");
for(i = 0; ; i++)
{
scanf("%d", &marks[i]);
if(marks[i] <= 0) {
break;
}
a++;
total += marks[i];
}
f = (float)total/(float)a;
printf("Average marks in Mathematics: %.2f\n", f);
return 0;
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال