Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
  6. int n,i;
  7. float c,big;
  8.  
  9. printf("\n\nEnter the number of elements you wish to find the greatest element of: ");
  10. scanf("%d", &n);
  11. printf("\n\nEnter %d numbers :\n", n);
  12.  
  13. printf("\n\n\t\t\tElement 1: ");
  14.  
  15. //Important step- always initialize big to the first element
  16. scanf("%f", &big);
  17.  
  18. for(i = 2; i <= n; i++)
  19. {
  20. printf("\n\t\t\tElement %d : ", i);
  21. scanf("%f", &c);
  22. /*
  23. if input number is larger than the
  24. current largest number
  25. */
  26. if(big < c)
  27. big = c; // update big to the larger value
  28. }
  29.  
  30. printf("\n\n\nThe largest of the %d numbers is %f ", n, big);
  31. printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement