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
What prefix describes a mass that is 1000 times smaller than a gram
yanalaym [24]
Milli as in milligram
4 0
3 years ago
Read 2 more answers
What sort of technique would you use to sort 10,000 items using just 1000 available slot in your RAM?
beks73 [17]

Answer:

d. Merge sort

Explanation:

Merge sort is example of an efficient sorting alogrithm. The Divide and conquer rule is used in this technique. This method breakdown the list into multiple sublists and each sublist contains a single element. This technique merged in the form of sorted lists. This technique uses external memory of the system while sorting.

Merge sort is used to sort the 10,000 items using only 1,000 slots available in the RAM.

5 0
3 years ago
Why is this app here to help but wont let me see answers to my questions?
UkoKoshka [18]

Answer:

maybe you need to reload the page and press the little bell on the right side and u should get a notification when somebody answers your question and if that doesnt help go to your profile and press the tab (on this tab if that makes since) it should say sumin like questions you asked and u should press the ones u need the answers to

Explanation:

lmk if this helped

5 0
3 years ago
Read 2 more answers
(Language: Python) How can you know what value is in a variable by looking at the code?
tatuchka [14]

Answer:

B. It’s always a string that matches the variable name.

4 0
2 years ago
Write a method named decimalToBinary that accepts an integer as a parameter and returns an integer whose digits look like that n
zmey [24]

Answer:

In Java:

public static int decimalToBinary(int decimal){

int binary = 0; // initial value

int currUnitPlace = 1; // working location

while(decimal > 0) {

// put remainder in current unit place

binary += currUnitPlace * (decimal%2);

decimal /= 2; // move to next bit

currUnitPlace *= 10; // move unit place

}

return binary;

}

7 0
3 years ago
Other questions:
  • Qu'est-ce qui motive le choix d'une autre?
    7·1 answer
  • What stage of software development incorporates planning to help make changes in the project plan based of reviews
    12·1 answer
  • How does a hard drive work?
    5·1 answer
  • Int a=10 int b=20<br> A=b<br> The new values for a and b are
    11·2 answers
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • What are ya'll discords???
    10·2 answers
  • B. What significant values have you learned while learning the tools and utensils?
    8·1 answer
  • what does it mean if you get the brainlyest ?and why does everyone want it so bad? and how do i give it to someone?
    6·1 answer
  • It is a type of web page that allows you to share your ideas experiences and beliefs
    9·1 answer
  • Rudy accidentally sent a sensitive work report to a personal friend named James instead one of his co-workers, who is also named
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!