Assuming int x = 0; int y = 0; int value = 0; char op_code = '0';
Question:
Assuming
int x = 0; int y = 0; int value = 0; char op_code = '\0';a) Write code to ask users to enter integers for x and y and a character either '+' or '-' or '*' for the op code.
b) Write an if else statement to perform the following: if op_code is '+' add x and y then store the result in the value variable. If op_code is '-' subtract y from x then store the result in the value variable. If op_code is '*' then multiply x and y andstore the result in the value variable. If op_code is anything else set value to -1.
c) The above if else statement is not efficient. Replace it using a switch statement.
2) (8 points)
Write a for loop that keeps asking users to enter a positive integer for 1000 times. Count the number of odd integers. Output the result after the for loop is done using a field width of 5 with leading zeros. For example if the odd integer count is 376 then the output must show 00376. Declare necessary variables with proper naming convention and initialization at declaration.