Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that enters a number n and after that enters more n numbers and calculates and prints their sum. Note that you may need to use a for-loop.
- using System;
- class SumOfNnums
- {
- static void Main()
- {
- Console.Write("How many numbers you want to enter: ");
- string display = Console.ReadLine();
- double a = double.Parse(display);
- double sum = 0;
- for (int i = 0; i < a; i++)
- {
- Console.Write("Enter number: ");
- string numbs = Console.ReadLine();
- double newnumbs = double.Parse(numbs);
- sum = sum + newnumbs;
- }
- Console.WriteLine("The sum is: " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement