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
Which of the following is not a true statement about Christopher Columbus it oko
Thepotemich [5.8K]

Answer:

  • There has been a need to explore the different regions across the globe in the early ages, as there were ships to travel but there was no one before who knew about the different routes and maps of the region, so, it was sort of blind folded traveling when some one wanted to go far distances yet some of them knew about other regions on the far sides of many seas having a unique culture, different languages, along with having diversity among the flora and fauna inside the region.
  • So, like many other curious people across the globe there was a need for the people to explore all the regions. As, it was a need for the travelers and all the rest of free fork to know about this world. Now, every wanted to know more about the different lands but there were few who even performed the great feat, as they had fear for their lives.While, Christopher Columbus was more into sacrificing his own life in order to explore the lands at the far lands across the Pacific ocean. As, he arranged his mind and covered all the required arrangements for the journey.
  • As, was at first wanted to explore the lands of far east and thus wanted to more about the Subcontinent India, but in turn he reached the lands of the American continent in far west.While, upon arriving the American region we say many people with different skin tone, culture and language which was very different then he heard about the people of India.There was more different world then he could ever think of as he had a lot to tell about these lands upon the way back to Europe or his home land.

7 0
3 years ago
What are these receivers called?
AlexFokin [52]

Answer: Cell site / Base station

Explanation:

A mobile network also referred to as the cellular network is refered to as the radio network which is distributed over the land areas which are refered to as the cells.

We should note that each is served by at least one fixed-location transceiver, which is called the cell site or the base station.

4 0
2 years ago
Whenever you are designing a project for commercial use (making money) and need to use photographs with people in them you must
Leya [2.2K]

Answer:

Copyright

Explanation:

7 0
3 years ago
Proszę daje wszystko potrzebuje tego
Stolb23 [73]
I’m sorry I do not speak that
5 0
3 years ago
Read 2 more answers
write a C program that declares an integer variable called "favorite_number". The program should then prompt the user to enter t
Arturiano [62]

Answer:

// here is code in C.

// headers

#include <stdio.h>

// main function

int main(void) {

// variable declaration

int favorite_number;

 // ask user to enter favorite number

printf("enter your favorite number : ");

 // read the number

scanf("%d",&favorite_number);

 // print the message

printf("your favorite number is: %d",favorite_number);

return 0;

}

Explanation:

Declare a variable "favorite_number" of integer type.Ask user to enter favorite number and assign it to favorite_number.Then print the message which include the favorite number.

Output:

enter your favorite number : 77

your favorite number is: 77

4 0
3 years ago
Other questions:
  • Fix the 2 error codes.
    14·1 answer
  • Which RFC reserves three ranges of IP addresses for private use - a single Class A (10.0.0.0-10.255.255.255), 16 Class Bs (172.1
    15·1 answer
  • What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
    10·2 answers
  • why is it important for you to understand and describe the internal and external components of a computer in the workplace​
    14·1 answer
  • Please Help!
    6·2 answers
  • It is an island country; it fought against us in World War II; it is known for sushi.
    14·2 answers
  • Create a variable in php to store your university information and parse using jQuery Ajax and print your name. The variable must
    12·1 answer
  • TOT al<br>Name TWO examples of these settings and utilities. (2)​
    12·1 answer
  • Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
    14·1 answer
  • What dictionary operation can you use to remove all the keys within the dictionary-named contacts?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!