91学习

陪伴你每一天!

结构体变量作为函数参数输出学生成绩

#include <stdio.h>


struct Student{

char cName[20];

float fScore[3];

}student={"SuYuQun",98.5f,89.0,93.5f};

void Display(struct Student stu){

printf("-----Information------\n");

printf("Name:%s\n",stu.cName);

printf("Chinese:%.2f\n",stu.fScore[0]);

printf("Math:%.2f\n",stu.fScore[1]);

printf("English:%.2f\n",stu.fScore[2]);

printf("Average score:%.2f\n",(stu.fScore[0]+stu.fScore[1]+stu.fScore[2])/3);

}

int main(){

Display(student);

return 0;

}

加威信18790284560免费送POS机.jpg

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。