stefan1919

Sum 5 Elements

Jul 20th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. namespace novo2
  8. {
  9.     class Program
  10.     {
  11.         static int a;
  12.         static void Main(string[] args)
  13.         {
  14.             string p;
  15.             p = Console.ReadLine();
  16.             string[] numbers = p.Split(' ');
  17.             double sum = 0;
  18.             double numberToSum;
  19.             for (int i = 0; i < numbers.Length; i++)
  20.             {
  21.              numberToSum = Convert.ToDouble(p.Split(' ')[i]);
  22.                sum = sum + numberToSum;
  23.             }
  24.             Console.WriteLine(sum);
  25.             }
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment