Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- struct student{
- char name[30];
- int eng;
- int math;
- double mean;
- }std[3];
- int calculate(char name[30],int eng,int math);
- void print(int engmax,int engmaxname);
- int main(){
- int i=0;
- while(i<3){
- printf("enter your name [%d]: ",i+1);
- scanf("%s",&std[i].name);
- printf("enter your point eng [%d]: ",i+1);
- scanf("%d",&std[i].eng);
- printf("enter your point math [%d]: ",i+1);
- scanf("%d",&std[i].math);
- printf("student[%d] : name : %s \npoint eng : %d \npoint math : %d\n",i+1,std[i].name,std[i].eng,std[i].math);
- i++;
- }
- i=0;
- while (i<3){
- calculate(std[i].name,std[i].eng,std[i].math);
- i++;
- }
- return 0;
- }
- int calculate(char name[30],int eng,int math){
- int i;
- int engmax=-1;
- int engmaxname=0;
- char higheareng[30];
- i=0;
- while (i<1){
- printf("mean : %d \n",(std[i].math+std[i+1].math+std[i+2].math)/3);
- i++;
- }
- i=0;
- while (i<3){
- if(engmax<std[i].eng){
- engmax=std[i].eng;
- //strcpy(higheareng, std[i].name);
- engmaxname=i;
- }
- i++;
- }
- print(engmax,engmaxname);
- }
- void print(int engmax,int engmaxname){
- printf("name eng max : %s\n",std[engmaxname].name);
- printf("point eng max : %d\n",engmax);
- }
Add Comment
Please, Sign In to add comment