Part A. Write a program WhileLoops that uses while loops to perform the followin
ID: 3859670 • Letter: P
Question
Part A. Write a program WhileLoops that uses while loops to perform the following steps 1. Prompt the user to input two positive integers: firstNum and secondNum (firstNum must be smaller than secondNum). 2. Output all the even numbers between firstNum and secondNum inclusive 3. Output the sum of all the even numbers between firstNum and secondNum inclusive. 4. Output all the odd numbers between firstNum and secondNum inclusive. 5. Output the sum of all the odd numbers between firstNum and secondNum inclusive. EXAMPLE OUTPUT: Enter an integer: Enter another integer larger than the first one 10 Even numbers 4 6 8 10 Sum of even numbers 28 Odd numbers 3 5 7 9 sum of odd numbers F 24Explanation / Answer
#include <stdio.h>
int main()
{
int i, n,m;
Printf("Enter an integer: ");
scanf("%d", &n);
Printf("Enter an integer larger than first one:");
scanf("%d", &m);
i=n;
while(i<=m)
{
if(i%2==0)
{
printf("Even numbers");
printf("%d ", i);
sum=sum+i;
printf("sum of even numbers");
printf("%d ", sum);
}else
{
printf("Odd numbers");
printf("%d ", i);
sum=sum+i;
printf("sum of odd numbers");
printf("%d ", sum);
}
i++;
}
return 0;
}
While loop is use to continue the processing until condition in while gets false