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
egoroff_w [7]
2 years ago
12

write a program in C# that reads a set of integers and then finds and prints the sum of the even and odd integers?​

Computers and Technology
1 answer:
trapecia [35]2 years ago
5 0

Answer:

The program in C# is as follows:

using System;

class Prog {

 static void Main() {

   int n;

   Console.WriteLine("Number of integers: ");

   n = Convert.ToInt32(Console.ReadLine());

   int evensum = 0, oddsum = 0; int inpt;

   for(int i = 0;i<n;i++){

       inpt = Convert.ToInt32(Console.ReadLine());

       if(inpt%2==0){            evensum+=inpt;        }

       else{            oddsum+=inpt;        }

   }

    Console.WriteLine(evensum);

    Console.WriteLine(oddsum);

 }

}

Explanation:

This declares n, the number of integer inputs

   int n;

This prompts for n

   Console.WriteLine("Number of integers: ");

This gets input for n

   n = Convert.ToInt32(Console.ReadLine());

This declares and initializes the even and odd sum.

   int evensum = 0, oddsum = 0; int inpt;

This iterates through n

   for(int i = 0;i<n;i++){

This gets each input

       inpt = Convert.ToInt32(Console.ReadLine());

Check for even numbers and add,if even

<em>        if(inpt%2==0){            evensum+=inpt;        }</em>

Otherwise, add input as odd

<em>        else{            oddsum+=inpt;        }</em>

   }

Print even sum

    Console.WriteLine(evensum);

Print odd sum

    Console.WriteLine(oddsum);

 }

You might be interested in
.) Write a complete C program in one file which takes a double value from the user, cubes it, and prints the result. Your progra
Ket [755]

Answer:

Explanation:

#include <iostream>

using namespace std;

double cube(double);

int main()

{

   double ci=0;

   cout << "Enter avalue :";

   cin >> ci;

   cout << "Cube of " << ci << "is =" << cube(ci) << endl;

   return 0;

}

double cube(double i)

{

   return(i*i*i);

}

8 0
3 years ago
When you insert a new slide in a presentation, where is it placed in relation to the existing slides?.
sladkih [1.3K]
Whenever you create a new slide, it appears below the selected slide.

If you have 2 slides and want one in between the two select the first slide and then select new slide.
4 0
2 years ago
Howard is leading a project to commission a new information system that will be used by a federal government agency. He is worki
Ann [662]

Answer:

The correct answer is A.

Explanation:

Given the example in the question, Howard is at the step of implementing security controls.

There are five official steps for the risk management framework.

  1. Categorizing The Information System: In this step, the IT system's objectives are assigned based on the current mission or project.
  2. Selecting Security Controls: After the risk assesment is done, the security controls for technical, hardware and software problems are decided according to the outcome.
  3. Implementing Security Controls: In this step, the points that were decided in the step before are put into action.
  4. Authorizing The Information System: Authorization for the risk management is approved and monitored.
  5. Monitoring Security Controls: The authorities keep monitoring the process and makes any necessary changes and updates.

The process that is explained in the question is step 3, which is given in option A.

I hope this answer helps.

5 0
3 years ago
How do you go about inserting additional worksheets into a workbook?
kicyunya [14]
The correct answer is D. All of the methods listed above are ways of inserting new sheets into a workbook.
6 0
3 years ago
This function returns the length of a string:
Anna71 [15]

Answer:

The strlen() function calculates the length of a given string.The strlen() function is defined in string.h header file.

Explanation:

It doesn’t count null character ‘0’. Syntax: int strlen(const char *str); Parameter: str: It represents the string variable whose length we have to find. Return: This function returns the length of string passed.

4 0
1 year ago
Other questions:
  • Bit rate is a measure of how many bits of data are transmitted per second. Compared to videos with a higher bit rate, the same v
    13·1 answer
  • Suppose a data broker correctly identifies that your grandmother is addicted to playing online hearts. From its business intelli
    8·1 answer
  • The unique physical address burned into every network interface card is its:
    15·1 answer
  • 18. Using the same formatting elements and designs across slides in a presentation is important to develop?
    5·1 answer
  • A palindrome is a word or phrase that reads the same both backward and forward. The word ""racecar"" is an example. Create an al
    15·1 answer
  • Determine if the following statement is true or false:
    5·2 answers
  • A network administrator determines who may access network resources by assigning users
    10·1 answer
  • Write a method named lastIndexOf that accepts an array of integers and an * integer value as its parameters and returns the last
    15·1 answer
  • How to fix a light blub
    11·2 answers
  • What is one disadvantage of transmitting personal data using digital signals?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!