How to write a C Program Structure Example in C Programming Language ?
Solution For C Program ://C Program Structure Example.
#include <stdio.h>
typedef struct {
char name[80];
int chineseScore;
int englishScore;
int mathScore;
int age;
int blood; // 1:A, 2:B, 3:AB, 4:O
} Student;
/*
(1)
void printStudent(char *name, int chineseScore, int englishScore, int mathScore, int age, int blood){
printf("%s:\n", name);
printf("Chinese results: %d\n", chineseScore);
}
(2)
*/
/*
int a;
struct Student a;
*/
void printStudent(Student s){
printf("%s:\n", s.name);
printf("Chinese results: %d\n", s.chineseScore);
}
int main(){
/*
(1)
char name[80] = "Sam";
int chineseScore = 100;
int englishScore = 95;
int mathScore = 80;
int age = 18;
int blood = 1;
printStudent(name, chineseScore, englishScore, mathScore, age, blood);
(2)
*/
Student a = { "Sam", 100, 95, 80, 18, 1 };
printStudent(a);
return 0;
}