0% found this document useful (0 votes)
53 views

It Ec 114 Assignment 2

This C program contains code for an assignment on structured programming. It defines a structure called studentInfo that contains student name, project marks, homework marks, and average calculations for projects and homework. It includes main, input, and output functions. The input function takes student data and calculates averages, while the output function prints the student name, project average, and homework average.

Uploaded by

yawahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

It Ec 114 Assignment 2

This C program contains code for an assignment on structured programming. It defines a structure called studentInfo that contains student name, project marks, homework marks, and average calculations for projects and homework. It includes main, input, and output functions. The input function takes student data and calculates averages, while the output function prints the student name, project average, and homework average.

Uploaded by

yawahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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