Write a program that adds the positive odd numbers you enter from the keyboard while ignoring the even numbers, and stops when a negative number or zero are entered.
Display the sum of the accepted odd numbers.
for( int i = 1; i <= N; i = i + 2){
sum = sum + i;
}
This is nonsense. What are you doing? You're supposed to add the number inputted to the sum if it's positive and odd. This for loop is something completely different.
You're supposed to keep reading input until a negative number (or zero) is entered, but you read just one number. You've ignored the instructions.