Advertisement
anonymzz

Method 2

Mar 15th, 2023
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /*
  4. ---------------------------------------------------------------------------------
  5.   Method 2
  6. ---------------------------------------------------------------------------------
  7. */
  8.  
  9. // begin main function
  10. int main(void)
  11. {
  12.     int modCount = 1, marks, sum1 = 0, sum2 = 0, sum3 = 0; //declaration variables
  13.  
  14.     // for Get Student 01 Total marks
  15.     while (modCount <= 4)
  16.          {
  17.              printf("Enter Student 01 Module %d Marks: ", modCount);
  18.              scanf("%d", &marks);
  19.  
  20.              sum1 = sum1 + marks;
  21.              modCount++; // increment modCount
  22.          }
  23.  
  24.     modCount = 1; // reset ModuleCount
  25.     printf("Student 01 Total Marks = %d\n\n", sum1); // Display Student 1 toatal marks
  26.  
  27.  
  28.     // for get Student 02 Total Marks
  29.     while (modCount <= 4)
  30.          {
  31.              printf("Enter Student 01 Module %d Marks: ", modCount);
  32.              scanf("%d", &marks);
  33.  
  34.              sum2 = sum2 + marks;
  35.              modCount++; // increment ModuleCount
  36.          }
  37.     modCount = 1; // reset ModuleCount
  38.     printf("Student 01 Total Marks = %d\n\n", sum2);
  39.  
  40.     // for get student 03 Total marks
  41.     while (modCount <= 4)
  42.          {
  43.              printf("Enter Student 01 Module %d Marks: ", modCount);
  44.              scanf("%d", &marks);
  45.  
  46.              sum3 = sum3 + marks;
  47.              modCount++; // increment ModuleCount
  48.          }
  49.     modCount = 1; // reset ModuleCount
  50.     printf("Student 01 Total Marks = %d\n\n", sum2);
  51.  
  52.     // For find Highest Marks and Student
  53.     if (sum1 > sum2 && sum2 > sum3)
  54.         printf("Highest Marks = %d By Student 01\n", sum1);
  55.  
  56.     else if (sum2 > sum1 && sum2 > sum3)
  57.         printf("Highest Marks = %d By Student 02\n", sum2);
  58.  
  59.     else if (sum3 > sum1 && sum3 > sum2)
  60.         printf("Highest Marks = %d By Student 03\n", sum3);
  61.  
  62.     else if (sum1 == sum2 && sum2 == sum3)
  63.         printf("All students gets Equal marks\n");
  64.  
  65.     else if (sum1 == sum2 && sum2 > sum3)
  66.         printf("Highest Marks = %d By Student 01 and 02\n", sum1);
  67.  
  68.     else if (sum1 == sum3 && sum3 > sum2)
  69.         printf("Highest Marks = %d By Student 01 and 03\n", sum1);
  70.  
  71.     else if (sum2 == sum3 && sum3 > sum1)
  72.         printf("highest Marks = %d By Student 02 and 03\n", sum2);
  73.  
  74.     else
  75.         printf("f*cking error\n");
  76.  
  77.     return 0;
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement