Question: Write a program that uses while loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNum (firstNum must be

Write a program that uses while loops to perform the following steps:

  • Prompt the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum)
  • Output the sum of the square of the odd integers between firstNum and secondNum
  • Output all odd integers between firstNum and secondNum, in ascending order
  • Output the sum of all even integers between firstNum and secondNum
  • Output the integers and their squares between firstNum and secondNum, in descending order
  • Output all the UPPERCASE letters

All ranges include the end points (firstNum and secondNum).

For Example:

Enter two integers. First number must be less than the second number you enter Enter 2 integers numbers: 10 20

Sum of the squares of odd integers between 10 and 20 = 1165 Odd integers between 10 and 20 are: 11 13 15 17 19 Sum of even integers between 10 and 20 = 90 Number Square of Number 20 400 19 361 18 324 17 289 16 256 15 225 14 196 13 169 12 144 11 121 10 100

Upper case letters are: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Here's my code:

#include

#include

int main() {

int num1;

int num2;

int mul3=0;

int mul5=0;

printf("Enter two integers: ");

scanf("%d %d",&num1, &num2);

printf(" ");

int n1=abs(num1);

int n2=abs(num2);

if(n1

{

while(n1<=n2)

{

if(n1%3==0)

mul3=mul3+1;

if(n1%5==0)

mul5=mul5+1;

n1++;

}

}

else

{

while(n2<=n1)

{

if(n2%3==0)

mul3=mul3+1;

if(n2%5==0)

mul5=mul5+1;

n2++;

}

}

if(num1>num2){

printf("Number of multiples of 3 between %d and %d is: %d ",num2,num1,mul3);

printf("Number of multiples of 5 between %d and %d is: %d ",num2,num1,mul5);

}

else{

printf("Number of multiples of 3 between %d and %d is: %d ",num1,num2,mul3);

printf("Number of multiples of 5 between %d and %d is: %d ",num1,num2,mul5);

}

return (0);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!