Advertisement
ShadmanTaqi

Assignment4, task 2

Mar 10th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n=3,i,j,k,t=0,s=0,f=0,term1,term2,hl=0,ll=0;
  5. float avg,r=0;
  6. int a[3],m[3];
  7. printf("Enter the Quiz Scores of students (Quiz 1, Quiz 2, Quiz 3):\n");
  8. for(i=1; i<=n; i++)
  9. {
  10. printf("Roll %d: ",i);
  11. for(j=0; j<3; j++)
  12. {
  13. scanf("%d",&a[j]);
  14. s=s+a[j];
  15. }
  16. for(k=i-1; k<i; k++)
  17. {
  18. m[k]=s;
  19. t=t+s;
  20. s=0;
  21. }
  22. }
  23. avg=t;
  24. r=avg/n;
  25. term1=a[0];
  26. term2=a[0];
  27. for(i=1; i<n; i++)
  28. {
  29. if(term1<a[i])
  30. {
  31. term1=a[i];
  32. hl=i;
  33. }
  34. }
  35. for(i=1; i<n; i++)
  36. {
  37. if(term2>a[i])
  38. {
  39. term2=a[i];
  40. ll=i;
  41. }
  42. }
  43. printf("\n\nThe Total Quiz Scores are:\n");
  44. for(i=0; i<n; i++)
  45. {
  46. f=i+1;
  47. printf("Roll %d: %d\n",f,m[i]);
  48. }
  49. printf("\n\nThe Class average of Total Quiz Score is: %.2f\n\n",r);
  50. printf("The Highest Total Score is: %d\n",term1);
  51. printf("The Highest Scorer Roll: %d\n\n",++hl);
  52. printf("The Lowest Total Score is: %d\n",term2);
  53. printf("The Lowest Scorer Roll: %d\n\n",++ll);
  54. return 0;
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement