Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. int a,b,c,d,max,sum,n;
  8. sum = 0;
  9. max = 0;
  10. n = 1;
  11. c = 0;
  12. printf("Enter B=");
  13. scanf("%d", &b);
  14. printf("Enter your numbers=");
  15. scanf("%d", &a);
  16. while (a != 0)
  17. {
  18. if ((a > (b * -1)) && (a < b) && (b > 0))
  19. {
  20. sum = sum + a;
  21. if (abs(a) > max)
  22. {
  23. max = a;
  24. c = n;
  25. }
  26. }
  27. else
  28. if ((a < (b * -1)) && (a > b) && (b < 0))
  29. {
  30. sum = sum + a;
  31. if (abs(a) > max)
  32. {
  33. max = a;
  34. c = n;
  35. }
  36. }
  37. n = n + 1;
  38. scanf("%d", &a);
  39. }
  40.  
  41. printf("Sum is = %d , Number of max number is = %d", sum , c);
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement