Nested for loops in C programming

Anonymous
timer Asked: Dec 4th, 2015
account_balance_wallet $5

Question Description

printf("\nEnter the Math score: ");

scanf("%d",&stud[i].mscore);

printf("\nEnter the English Score: ");

scanf("%d",&stud[i].escore);

stud[i].avg =(stud[i].mscore+stud[i].escore)/2;

}

}

void top (void){

    int a=1;

for(i=0;i<n-1;i++)

{

for(j=i+1;j<n;j++)

{

if(stud[i].avg<stud[j].avg)

{

t=stud[i]; ***********

stud[i]=stud[j];  *********

stud[j]=t; *********

}

Can somebody please explain what is happening in the lines with the asterick? Let me know if you need the entire program

Tutor Answer

martisdavid
School: New York University

Thank you for the opportunity to help you with your question!

Thank you for the opportunity to help you with your question!

First the programe tries  to evaluate whether  t is average by first checking whether is equal to what is stored in array  stud i and if it is equal it goes further and evaluate whether array stud i is equal to array stud j 

Thus  t results is equal to arry stud j and thus  they  have been able to know t is average 

Please let me know if you need any clarification. I'm always happy to answer your questions.Please let me know if you need any clarification. I'm always happy to answer your questions.

flag Report DMCA
Review

Anonymous
Goes above and beyond expectations !

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors