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
There are several methods of updating information and data on a webserver. We must consider who performs those updates upfront w
Thepotemich [5.8K]

Answer:

RTMC pro, HTML server-sent and Java Software Development Kit

Explanation:

<u>RTMC pro</u>:  The setup of RTMC pro is done automatically and there is provision of several elements to upload and store data on the server using screens. Screens are usually saved as files and then integrated to an internal or external server.

<u>HTML server-sent</u> : This is a way for webpages to communicate with the webserver. In this method, for ever HTML page there is an associated script present on the server side that will continuously provide realtime data update. This scrip will have to be configured with the data you want to update.

<u>Java Software Development Kit</u> : JAVA SDK is used to build software/applications on Java. This permits programmers to develop applications or applets to perform data updating on the servers. The developped applets can be used with internal servers as well as third party servers.

5 0
3 years ago
Read 2 more answers
Privacy Group of answer choices must be respected if we are to function as complete, self-governing agents is an absolute value
ElenaW [278]
Privacy group in article 3 in constitution section 3 too
8 0
2 years ago
If variable x has value 2 and y has value 2, what is the value of the following Jack expression?
saul85 [17]

Answer:

The value of the following expression is "2".

Explanation:

Here x has value 2 means x=2,and y has value 2 means y=2.

so (x+3)/(4-y)

  (2+3)/(4-2)

5/2 it gives 2 because /(slash) operator gives the quotient part .The slash    operator divide the left hand operand by the right hand operand.On dividing 5/2 it returns integer value i.e 2.

3 0
3 years ago
4
madam [21]

Answer:

its the basic link

Explanation:

6 0
2 years ago
Read 2 more answers
What does a professional programmer usually do first to gain an understanding of a problem?
ElenaW [278]
The correct answer to your question is:

Professional programmers work directly with, and interview customers to find out what the problem is.
6 0
2 years ago
Read 2 more answers
Other questions:
  • An author is preparing to send their book to a publisher as an email attachment. The file on their computer is 1000 bytes. When
    6·1 answer
  • Briefly define "address space" and discuss its major tradeoffs (advantages/costs). What problem is it addressing?
    10·1 answer
  • 1. Zack sees an online contest. He could win $10,000 instantly! On the sign-up form, he enters his name and email address. He is
    15·1 answer
  • HELP PLEASE
    7·1 answer
  • Please answer this simple (hard) question for me lol
    13·2 answers
  • SOMEONE PLEASE HELP ME OUT WITH THIS PLEASE
    13·1 answer
  • Is iphone battery being draned if plugged into car charger when listening to podcasts
    6·1 answer
  • Need help finding the totals and with the empty spots
    9·1 answer
  • What is software?
    6·1 answer
  • The Synonyms submenu offers a list of synonyms for a word. Is it always a good idea to use whatever synonyms are presented on th
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!