- Write a program that prompts the user to input two integers: num1 and num2 (where num1 must be less than num2), then making use of a while loop:
Output (ie display) all odd numbers between num1 and num2 (inclusive). Output the sum of all even numbers between num1 and num2 ( " ). Output the sum of the square of odd numbers between num1 and num2 ( " ).
Eg:
Enter 2 numbers (num1 < num2) : 2 9 The odd numbers between 2 and 9 are : 3 5 7 9 The sum of even numbers are : 20 The sum of squares of odd numbers are : 164
I've tried solving this for about 2 hours now and here is my progress so far and I dont know where to go from here:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)
#include<math.h>
int main() {
int num1,num2;
printf("Enter 2 integers = ");
scanf("%d%d", &num1, &num2);
while (num1 < num2)
num1++;
if (num1 % 2 == 0) {
printf("The even number are =%d\n", num1);
}
else{
printf("The odd numbers are =%d\n", num1);
}
return 0;
}