Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  asignment
Language: C/C++
Code:
#include<stdio.h>      //header file
int total_mks=100;     //global variable declaration
struct stu_details
{
     char choice,stu_nm[20];
     int mrks_mth,mrks_sci,mrks_sosci,mrks_eng;  //variable declaration
     float mrks_avg,get_mrk;
     
};
struct stu_details data_input()
{
     struct stu_details sd;
     do
     {
          printf("Enter the name of the student:");
          gets(sd.stu_nm);
          printf("Enter the subject marks of Math:");
          scanf("%d",&sd.mrks_mth);
          printf("Enter the subject marks of Science: ");
          scanf("%d",&sd.mrks_sci);
          printf("Enter the subject marks of social science:");
          scanf("%d",&sd.mrks_sosci);
          printf("Enter the subject marks of English:");
          scanf("%d",&sd.mrks_eng);
          printf("Do you want to add more student records(Y/N):n");
          scanf("%c",&sd.choice);
          return(sd);
          
     }while(sd.choice=='y' ||'Y');
     
}

struct stu_details data_process(struct stu_details sd2)
{
     struct stu_details temp;
     temp.get_mrk=temp.mrks_mth+temp.mrks_sci+temp.mrks_sosci+temp.mrks_eng;
     temp.mrks_avg=temp.get_mrk/4;
     return(temp);
}
void display(struct stu_details disp)
{
     printf("tt STUDENT GRADE SHEETtn");
     printf("t_______________________n");
     printf("NAMEt  MATH t SCIENCEt  SOCIAL SCIENCEt  ENGLISHt  TOTAL_MKSt AVG_MRKSn");
     printf("___________________________________________n");
     printf("%s %dt%dt%dt%dt%dt%f",disp.stu_nm,disp.mrks_mth,disp.mrks_sci,disp.mrks_sosci,disp.mrks_eng,disp.get_mrk,disp.mrks_avg);
     printf("n______________________________________________");
}



int main()             //STARTING OF MAIN FUNCTION
{
     struct stu_details sd1,pdata;
     sd1=data_input();
     pdata=data_process(sd1);
     display(pdata);
     return 0;

     
     
     
}

          
Comments: