Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int count=0, sum=0,n;
- while(1)
- {
- printf("Enter integer: \n");
- scanf("%d",&n);
- if(n<0)
- break;
- if(n%2)
- {
- ++count;
- sum+=n;
- }
- }
- printf("The sum is %d and the number of odd numbers is %d",sum,count);
- return 0;
- }
- //Output
- //Enter integer:
- //3
- //Enter integer:
- //2
- //Enter integer:
- //5
- //Enter integer:
- //2
- //Enter integer:
- //-123
- //The sum is 8 and the number of odd numbers is 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement