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]
3 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]3 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
Which of the following branches of government is NOT involved in Discretionary Fiscal Policy?
Ket [755]
Federal perserve hope this helps :)

6 0
3 years ago
There are many different types of documents that are used to convey information in the business world-letters and
Savatey [412]
I don’t know what the answer is I wish I could help
4 0
4 years ago
Ginny just enrolled in a C-SNP that uses the post-enrollment verification method. When will the plan send her a termination noti
Zolol [24]

The plan will be sent to her for a termination notification letter at the end of her first month of her enrollment.

<h3>What is a notification of termination?</h3>

A notice of termination is known to be that which is often given to an employee or a person and it states that it is the end of their employment or other contract.

Hence, The plan will be sent to her for a termination notification letter at the end of her first month of  her enrollment.

Learn more about verification method from

brainly.com/question/17274244

#SPJ1

6 0
2 years ago
Unit 2: Lesson 6 - Coding Activity 1
gogolik [260]

Answer:

easyy

Explanation:10 smaple runs and 2

4 0
3 years ago
What will be displayed in the console when this program runs?
Novay_Z [31]

Answer:

20 will be displayed on the console.

Explanation:

Given code is:

var numList = [10,20,30];

console.log(numList[numlist.length-2]);

The first line of code declares an array named numList and assigns it values given in the square brackets.

The second line of code is written to display the element on the index obtained by [numlist.length-2]

[numlist.length-2] means the second index.

Hence,

after running the code on JavaScript editor and dry running the code

20 will be displayed on the console.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which term is used to describe the science of examining raw data, removing excess noise from the dataset, and organizing the dat
    15·1 answer
  • For a wire with a circular cross section and a diameter = 3.00mm calculate the following: (m means meter. mm means millimeter. c
    5·1 answer
  • ALGUEM SABE COMO MUDA O NOME DE PERFIL!?!?!? SE SOUBER ME AJUDA!!
    14·1 answer
  • Create detailed pseudocode for a program that calculates how many days are left until Christmas, when given as an input how many
    15·1 answer
  • ¿porque y como surge la informatica y las computadoras
    13·1 answer
  • LAB: Convert to binary - methods
    11·1 answer
  • Whats with the bot spamming customer care numbers...kinda annoying when im trying to help people.
    12·1 answer
  • Rafi is developing an application to send urgent information about global health crises over the Internet to hospitals. He is wo
    6·1 answer
  • What will the computer do in response to a line of code reading # name = input("What is your name?")
    7·1 answer
  • You can easily merge files even if each file contains a different record layout. Group of answer choices True False
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!