fahimkamal63

Summation in C# -2

Oct 18th, 2021
579
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class Summation2
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter value of n: ");
  8.         int n = Convert.ToInt32(Console.ReadLine());
  9.         int sum = 0;
  10.  
  11.         for (int i = 1; i <= n; i++)
  12.         {
  13.             Console.Write("Enter value of number{0}: ", i);
  14.             int temp = Convert.ToInt32(Console.ReadLine());
  15.             sum += temp;  
  16.         }
  17.  
  18.         Console.WriteLine("The summation of all numbers is: {0}", sum);
  19.     }
  20. }
RAW Paste Data