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
How many host ids does a /20 network support?
BlackZzzverrR [31]
2^(32-20) - one for the network number - one for the broadcast address = 4,094
5 0
4 years ago
With "read" function, which one of the following statements is NOT correct? a.If the read is successful, the number of bytes rea
worty [1.4K]

Answer:

a. If the read is successful, the number of bytes read is returned.

b. If the end of file is encountered, 0 is returned.

Explanation:

A read function is one of the functions used in computer programming. A read function is used to read an information or data that was written before into a file.

If any portion of a regular file before to the end of file has not been written and the end of file is encountered the read function will return the bytes with value 0.

If read function has read some data successfully, it returns the number of bytes it read.

3 0
3 years ago
You just realized the turn signal on your vehicle is broken,
zimovet [89]

Answer:

c

Explanation:

7 0
4 years ago
What is redundancy? What problems are associated with redundancy?
Anarel [89]

Answer:

Redundancy is the mechanism that occurs in database's data as the same data is stores in the multiple location.It creates repeated data by accident or for backup purpose.

The issues that arise due to the redundancy of the data is the storage space in database gets consumed and thus wastes the space in storing information in multiple locations.When any update occurs in the stored data's field value , it also has to be changed in the multiples occurrences.

5 0
4 years ago
. The _____________ is the responsibility of the CISO, and is designed to reduce incidence of accidental security breaches by or
irinina [24]

Answer: SETA program

Explanation:

 The SETA program is basically stand for the security, education, training and awareness. It is basically used to reduce the accidental security which is break by the organization member such as employees, vendors and contractors.

The SETA program provided various benefits to the organization as it improve the behavior of the employees.It basically enhance the training and education program by focus and concentrate on the information security.

It can also inform he member of the organization about the report of violating many policies.

7 0
3 years ago
Other questions:
  • How to the inverse function of f(x)=x2 +1 ,x&gt;o
    5·1 answer
  • How do you transfer music from external hard drive to a laptop?
    13·1 answer
  • Which of the following is a safe work practice to protect you from electrocution hazards?
    14·1 answer
  • Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consis
    13·1 answer
  • Which type of password provides the highest level of permissions in bios?
    6·1 answer
  • What should a safe username do?
    14·2 answers
  • Many ____ classes for certification are available on the Internet and by many companies that have set up intranets within their
    15·1 answer
  • Which code block is an example of a motion block in scratch?
    12·1 answer
  • What is one difference between a web page and a web application?
    11·1 answer
  • when using screwdrivers you should always be aware that the screwdriver blade might slip out of the slot and strike you in the .
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!