Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _6.EvenAndOddSubstraction
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Write a program that calculates the difference between the sum of the even and the sum of the odd numbers in an array.
- string[] input = Console.ReadLine().Split();
- double sumEven = 0, sumOdd = 0;
- for (int i = 0; i < input.Length; i++)
- {
- double number = double.Parse(input[i]);
- if(number % 2 == 0)
- {
- sumEven += number;
- }
- else
- {
- sumOdd += number;
- }
- }
- Console.WriteLine(sumEven - sumOdd);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement