HERE IS THE QUESTION:
Problem 1.
Write a program that asks user to input an integer, input_int, in the range 10 to 20 (inclusive).
If the user enters an even number, the program computes and prints the even-numberseries
sum of all the even numbers, from 1 to input_int. And if the user enters an odd
number, then the program computes and prints the odd-number-series sum of all the odd
numbers, from 1 to input_int. However, if the user enters an invalid input (an integer less
than 10, or greater than 20), then the program prints an error message, and exits. Four
sample test runs are given below as examples of the input/output of the program. The
input/output of your program must be formatted the same as in the examples (red texts
indicate sample user inputs).
Test run 1:
Please input a positive integer (10 – 20): 15
The sum
1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 = 64
Test run 2:
Please input a positive integer (10 – 20): 12
The sum
2 + 4 + 6 + 8 + 10 + 12 = 42
Test run 3:
Please input a positive integer (10 – 20): 8
Input must be a positive integer (10 – 20).
Test run 4:
Please input a positive integer (10 – 20): 100
Input must be a positive integer (10 – 20).

HERE IS WHAT I HAVE SO FAR:
#include
int main()
{
int input_int;
printf(“Test run 1\n”);
printf(“\nPlease input a positive integer (10-20):\n”);
scanf(“%d”, &input_int);

If (input_int

SHOULD I USE AN IF ELSE STATEMENT?
or should i use a loop? if i do use a loop can you please provide some help with that
this is my first time taking programming, im really new

thanks
!


Error Code Related Sites

Tagged with: