Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

EASTERN MEDITERRANEAN UNIVERISTY

INFORMATION TECHNOLOGY

ITEC114

STRUCTURED PROGRAMMING

ASSIGNMENT 2

Mohamed Sanime Bin Abdel Wahab Amira

16700107

GROUP 1

ACADEMIC YEAR: FALL 2017 – 2018

December 29, 2017


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define NUM_OF_ELEMENTS 3

struct studentInfo{
char firstName[20];
int projectMarks[3];
int hwMarks[2];
float avg_Prj;
float avg_HW;
}student[5];

void input(struct studentInfo *std);


void output(struct studentInfo *std);

int main (void)


{
struct studentInfo std;
printf("\n\t\t\t\t ITEC114 Assignment 02 \n");
printf("\t\t\t Student: Mohamed Sanime Amira \n");
input(&std);
output(&std);
getchar();
getchar();
return 0;
}

void input(struct studentInfo *std){


int i,j;
float vavg=0;
for (i=0; i<NUM_OF_ELEMENTS; i++){

printf("\nStudent Name: ");


scanf("%s",(std+i)->firstName);
printf("\t Projects Marks:\n ");

2
for(j=0; j<NUM_OF_ELEMENTS; j++){
printf("\t\t Project %d: ",j+1);
scanf("%d",&(std+i)->projectMarks[j]);
vavg += (std+i)->projectMarks[j];
}
(std+i)->avg_Prj = vavg / 3;
vavg=0;
printf("\n\t HW Marks :\n ");
for(j=0; j<2; j++){
printf("\t\t HW %d: ",j+1);
scanf("%d",&(std+i)->hwMarks[j]);
vavg += (std+i)->hwMarks[j];
}
(std+i)->avg_HW = vavg / 2;
vavg=0;
}
}

void output(struct studentInfo *std){


int i,j;
printf("\nStudent Name \t\t Project Average \t HW Average\n");
for (i=0; i<NUM_OF_ELEMENTS; i++){
printf("%s \t\t\t %.2f \t\t\t %.2f\n",(std+i)->firstName,(std+i)->avg_Prj,(std+i)-
>avg_HW);
}
}

3
4

You might also like