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 23:50
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 03:10
Acomputer has a two-level cache. suppose that 60% of the memory references hit on the first level cache, 35% hit on the second level, and 5% miss. the access times are 5 nsec, 15 nsec, and 60 nsec, respectively, where the times for the level 2 cache and memory start counting at the moment it is known that they are needed (e.g., a level 2 cache access does not even start until the level 1 cache miss occurs). what is the average access time?
Answers: 1
question
Computers and Technology, 23.06.2019 04:20
Which network media uses different regions of the electromagnetic spectrum to transmit signals through air? uses different regions of the electromagnetic spectrum to transmit signals through air.
Answers: 2
You know the right answer?
#include <iostream> using namespace std;

int main()
{
int num1, num2,r...
Questions
Questions on the website: 13722360