Write a program which will take integer numbers as an array. Your program should stop taking input when it sees a negative integer. Then apply these 2 modifications to the array and print the resulting array.
- If an element is an even number, divide it by 2.
- If an element is an odd number, add the next element to it.
- Assume the last element of the array will always given as even number.
- Assume at most 100 elements will be entered before entering a negative number.
Examples:
6 -5 8 10 -1 9
|
3
|
1 10 -19
|
11 5
|
0 2 4 6 8 10 12 -5 2 -1
|
0 1 2 3 4 5 6
|
1 2 3 4 5 6 -10
|
3 1 7 2 11 3
|
Important issues about all exams/projects/quizzes:
- Update just Question.c file, not Question.txt.
- Make changes only between the following comments(DO NOT modify these comments or anything outside the region marked by the comments):
- // DO_NOT_EDIT_ANYTHING_ABOVE_THIS_LINE
- // DO_NOT_EDIT_ANYTHING_BELOW_THIS_LINE
- If you modify these comments for any reason, you can copy/paste the initial version from Question.txt into Question.c. Note that Question.txt is not graded at all, so anything you write in Question.txt will be discarded.
- To avoid getting the 'Binary Not Found' error, SAVE and BUILD your code before RUN.
- Do not add any extra messages message for input/output such as 'Enter an integer:', 'The result is:', etc. Any additional text that appears in the output will cause you to get no points from the question.
- Input and output of your program must be just like those in the Examples table above.