subject

#include <iostream> using namespace std;

int main()
{
int num1, num2,r, i;

cout<<"Enter a start: ";
cin>>num1;
cout<<"Enter an end: ";
cin>>num2;
cout<<"\n\nODD NUMBERS\n";

for(i=num1; i<=num2; i++){
r=i%2;
if(r==1)
cout<<" "<<i;

}
cout<<"\nEVEN NUMBERS\n";

for(i=num1; i<=num2; i++){
r=i%2;
if(r==0)
cout<<" "<<i;
}
if(num1>num2){
cout<<"ERROR! Starting Number is GREATER THAN the Ending Number!!!";
return 0;
}
}

Using while loop, do while and for loop write a C++ program that lets you input a starting and ending integer (range) then display all the odd integers and the even integers within the range then compute the sum of each set of integers.:

If the starting number is greater than ending number, the program should display “ERROR! Starting Number is GREATER THAN the Ending Number!!!”.

Sample output:

Enter a start: 1

Enter an end: 10

ODD NUMBERS

1 3 5 7 9 Sum: 25

EVEN NUMBERS

2 4 6 8 10 Sum: 30

the attached pic has been my progress so far. please help me reach the expected output.


#include <iostream>

using namespace std;int main(){ int num1, num2,r,i; cout<<Enter

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
How do you know if the website is secure if you make a purchase
Answers: 2
You know the right answer?
#include <iostream> using namespace std;

int main()
{
int num1, num2,r...
Questions
question
Mathematics, 10.11.2020 05:20
question
Social Studies, 10.11.2020 05:20
question
Mathematics, 10.11.2020 05:20
question
Spanish, 10.11.2020 05:20
question
Mathematics, 10.11.2020 05:20
question
Chemistry, 10.11.2020 05:20