Professional Documents
Culture Documents
* Filename : structure_example.c
* Author : Burak Kaleci
* Date : 12.04.2017
* Description : An example program to use structures with functions
* ******************************************************/
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
#define SIZE 5
// structure definition
struct student{
int idNumber;
char firstName[100];
char lastName[100];
char gender;
int age;
double GPA;
};
// function prototypes
void printStudent(struct student p);
double calculateAvgGPA(double s1,double s2);
void determineGender(char g, char* n);
void printStudentArray(struct student *pArray);
int countMaleStudent(struct student *pArray);
/* function main begins program execution each program must include main function */
int main(void)
{
//define student type variable and initialize it by using list
struct student aStudent={2037,"Burak","Kaleci",'M',32,3.55};
//assigning structure variables to structure variables of the same type is valid operat
studentArray[0]=aStudent;
studentArray[1]=aStudent2;
}
printf("----------------------------------------------------------------\n\n");
}
int i,pass;
switch (param){
case 1:
for(pass=0;pass<SIZE-1;pass++){
for(i=0;i<SIZE-1;i++){
if(studentArray[i].idNumber>studentArray[i+1].idNumber) {
}
}
}
break;
case 2:
for(pass=0;pass<SIZE-1;pass++){
for(i=0;i<SIZE-1;i++){
if(studentArray[i].gender>studentArray[i+1].gender) {
}
}
}
break;
case 3:
for(pass=0;pass<SIZE-1;pass++){
for(i=0;i<SIZE-1;i++){
if(studentArray[i].age>studentArray[i+1].age) {
}
}
}
break;
case 4:
for(pass=0;pass<SIZE-1;pass++){
for(i=0;i<SIZE-1;i++){
if(studentArray[i].GPA>studentArray[i+1].GPA) {
}
}
}
break;
}
}