Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- int main()
- {
- int a,b,c,d,max,sum,n;
- sum = 0;
- max = 0;
- n = 1;
- c = 0;
- printf("Enter B=");
- scanf("%d", &b);
- printf("Enter your numbers=");
- scanf("%d", &a);
- while (a != 0)
- {
- if ((a > (b * -1)) && (a < b) && (b > 0))
- {
- sum = sum + a;
- if (abs(a) > max)
- {
- max = a;
- c = n;
- }
- }
- else
- if ((a < (b * -1)) && (a > b) && (b < 0))
- {
- sum = sum + a;
- if (abs(a) > max)
- {
- max = a;
- c = n;
- }
- }
- n = n + 1;
- scanf("%d", &a);
- }
- printf("Sum is = %d , Number of max number is = %d", sum , c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement