1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anettt [7]
3 years ago
8

Write a program that reads an integer, and then prints the sum of the even and odd integers.

Computers and Technology
1 answer:
Tasya [4]3 years ago
6 0

Answer:

#include <iostream>  // header file

using namespace std;  // namespace

int main ()

{

int n, x1, i=0,odd_Sum = 0, even_Sum = 0;  // variable declaration

cout << "Enter the number of terms you want: ";

 cin >> n;  // user input the terms

cout << "Enter your values:" << endl;

  while (i<n)  // iterating over the loop

{

cin >> x1;  // input the value

if(x1 % 2 == 0)  // check if number is even

{

even_Sum = even_Sum+x1;  // calculate sum of even number

}

else

{

odd_Sum += x1; // calculate sum of odd number.

}

i++;

}

cout << "Sum of Even Numbers is: " << even_Sum << endl;  // display the sum of even number

cout << "Sum of Odd Numbers is: " << odd_Sum << endl;  // display the sum of odd number

return 0;

}

Output:

Enter the number of terms you want:3

Enter your values:2

1

78

Sum of Even Numbers is:80

Sum of Odd Numbers is:1

Explanation:

In this program we enter the number of terms by user .After that iterating over the loop less then the number of terms .

Taking input from user in loop and check the condition of even. If condition is true then adding the sum of even number otherwise adding the sum of odd number.

Finally print the the sum of the even number and odd integers.

You might be interested in
Interactive sites were usually is right about important topics and comments to a threaded discussion are called
iren2701 [21]
The answer to this question is:

Interactive sites were usually is right about important topics and comments to a threaded discussion are called"Blogs"

Hoped This Helped, Euniceortiz13
Your Welcome :)
8 0
3 years ago
7.1 Write statements that create the following arrays: A 100-element int array referenced by the variable employeeNumbers. final
maria [59]

Answer:

A. int [ ] numbers = new int[employeeNumbers];

B. double[ ] numbers = new double[payRates];

C. float[ ] miles = new float[14];

D. char[ ] letters = new char[1000];

7.2 Size of array cannot be negative

Size of array should be a positive integer and not decimal.

7.4 The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element in an array.

7.5 subscript to be out-of-bound means the specified integer is not within the range of the length of the array.

Explanation:

The question has answer given for some. I guess the explanation is what is needed.

A. The general format of creating an array is:

data type[] arrayRefVar=new datatype[size];

In this case, the datatype is int, arrayRefVar is numbers, size is employeeNumbers. The size was already initialised to 100 (employeeNumber).

B. A wrong datatype was used.

double[ ] numbers = new double[payRates];

would create an array of size 25 which is the payRates with types double.

C. The array was re-written using the general format of creating an array is:

data type[] arrayRefVar=new datatype[size];

D. The array was correctly defined.

7 0
4 years ago
Find some search engine as many that you can find
Alexandra [31]
1) google
2) bing
3) yahoo
4) safari
5) baidu
6) ask!
7) aol
8) duckduckgo
9) yandex
10 webcrawler
5 0
3 years ago
(ANSWER!)
andreev551 [17]

Answer:

it doesn't? maybe it helps by resetting it but other than that I don't think It does anything

4 0
3 years ago
Read 2 more answers
Cual es la <br> importancia de la netiqueta cuando nos comunicamos con el internet
jeka57 [31]

Answer: ight

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • The ____ directory contains configuration files that the system uses when the computer starts.
    7·1 answer
  • (PLS HELP 99 POINTS) In a paragraph of no less than 125 words, explain the three aspects involved in gaining a true appreciation
    14·2 answers
  • What kind of device is a printer? output or input
    13·1 answer
  • Consider the unsigned decimal number 35. What is the value in hexadecimal?<br><br> 1. 3510 = ____ 16
    13·1 answer
  • Which statement is most likely to be true about a computer network?
    11·2 answers
  • Janet has created a 3D movie. She wants to make a copy of the movie and store it for future use. Which device should she use?
    14·1 answer
  • Which two tasks are associated with router hardening? (choose two.)?
    6·1 answer
  • This the code from the last post I did
    8·1 answer
  • Contagem progressiva e regressiva usando estrutura condicional enquanto no visualg
    7·1 answer
  • Immigrants are allowed to enter the country to work when they have a(n)
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!