Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. /*********************************
  2. * Class: MAGSHIMIM C1            *
  3. * Week 5                         *
  4. * Alon Elay Latucha              *
  5. **********************************/
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9.  
  10. int main()
  11. {
  12.     int inputNum = 0, maxNum = -999, secondMaxNum = -999;
  13.     printf("Enter number: ");
  14.     scanf_s("%d", &inputNum);
  15.     maxNum = inputNum, secondMaxNum = inputNum;
  16.     do {
  17.         printf("Enter number: ");
  18.         scanf_s("%d", &inputNum);
  19.         if (maxNum < inputNum)
  20.         {
  21.             secondMaxNum = maxNum;
  22.             maxNum = inputNum;
  23.         }
  24.         else if (secondMaxNum < inputNum)
  25.         {
  26.             secondMaxNum = inputNum;
  27.         }
  28.     } while (inputNum != -999);
  29.     printf("First max: %d, Second max: %d\n", maxNum, secondMaxNum);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement