Structure
Hello, i've done the most part of my task.
But there is 1 more thing to do
Need to find the "avarege mark of the student with entered surname"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <stdio.h>
#include <conio.h>
#include <string.h>
struct Student
{
char code[15];
char surname[30];
char disciplin[50];
int mark;
};
int main()
{
int n;
printf("Enter number students: ");
scanf("%i", &n);
Student *st=new Student[n];
for (int i=0; i<n; i++)
{
printf("-----%i-----\n", i+1);
printf("Student Code:");
getchar();
gets(st[i].code);
printf("Surname: ");
gets(st[i].surname);
printf("Discipline: ");
gets(st[i].disciplin);
printf("Mark: ");
scanf("%i", &st[i].mark);
st[i].mark;
}
for (int i=0; i<n; i++)
printf("\n%i %s %s %i\n", i+1, st[i].surname, st[i].disciplin, st[i].mark);
{
float sum=0;
for (int i=0; i<0; i++)
sum+=st[i].mark;
sum/=n;
printf("Averege mark=%f\n", sum);
}
getch();
return 0;
}
|
Topic archived. No new replies allowed.