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
Develop a C program that calculates the final score and the average score for a student from his/her (1)class participation, (2)
White raven [17]

Answer:

Following are the code to the given question:

#include<iostream>//defining header file

using namespace std;

int main()//defining main method

{

float clspat,test,asst,exam,practice,total,average;//defining floating variable

char name[100];//defining char variable to input value

cout<<"Enter Name of Student: ";//print message

cin>>name; //input value

cout<<"Enter scores in following scoring items between 0 and 100:"<<"\n";//print message

cout<<"Enter class participation score: ";//print message

cin>>clspat;//input value

cout<<"Enter test score: ";//print message

cin>>test;//input value

cout<<"Enter assignment score: ";//print message

cin>>asst;//input value

cout<<"Enter exam score: ";//print message

cin>>exam;//input value

cout<<"Enter practice score: ";//print message

cin>>practice;//input value

total=clspat+test+asst+exam+practice;//calculating total value

average=total/5;//calculating average value

cout<<endl<<"SCORE CARD OF "<<name<<"\n"<<"-----------------------"<<"\n";//print value with message

cout<<"Total score: "<<total<<"\n";//print message with value

cout<<"Average score: "<<average; //print message with value

}

Output:

please find the attached file.

Explanation:

In this code, the floating-point variable is declared, which is used for input value from the user-end and after input the floating-point value it uses the "total, average" variable to calculate its respective values and store its value with init, after storing the value into the variable it uses the print method to print its values.

5 0
3 years ago
Which of the following answers refers to a system containing mappings of domain names to various types of data, such as for exam
Dvinal [7]

Answer:

Option B: DNS

Explanation:

Domain Name Server (DNS) is analogous to a phone book where people can look up a person name through numerical phone number. A DNS server is a database that host a database of public IP addresses (e.g. 64.233.160.0) and their associated hostname (e.g. google.com).

Whenever we type domain name in the address bar of our browser (e.g. google.com), that domain will be delivered to DNS server. Inside DNS server the URL will be mapped with its corresponding IP address making it possible for the web request to reach the the target server.

6 0
3 years ago
Match each command group under Picture Tools to the appropriate tasks.
FrozenT [24]

Answer:

look at the attachment for correct answers.

6 0
2 years ago
Dad Mystery - Continued
Anton [14]

Answer:

A server is a software or hardware that provides services to other client software or hardware devices including common data and resource sharing and carrying out computational task based on request from clients

A process of a client may located on the server or connected to a server from a different device through a network

Examples of servers are print servers, email servers, game servers, web servers, and database servers

Explanation:

6 0
3 years ago
Does anyone know the answer to this question
koban [17]
The answer would be D) because they want the best of the best
7 0
3 years ago
Other questions:
  • Blender questions
    8·1 answer
  • Of the two basic methods of data entry, keyboards use keystrokes to enter data and instructions; what is the nonkeyboard method
    8·1 answer
  • What adds the element carbon to the environment
    10·2 answers
  • What was a result of george washington's belief in the sovereignty of the people instead of monarchy?
    9·1 answer
  • A network administrator is reviewing a network design that uses a fixed configuration enterprise router that supports both LAN a
    8·1 answer
  • To erase a character to the right of the insertion point, press the ____ key(s).
    15·1 answer
  • As technology advances, does technology become more of less complex?
    14·1 answer
  • The insert options button lists formatting options. true or false.
    11·1 answer
  • 1. Which of the following is not true about high-level programming language s? (a) Easy to read and write (b) Popular among prog
    12·1 answer
  • When the user types into a Textbox control, the text is stored in the control's __________ property.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!