Advertisement
Spocoman

04. Print and sum

Jan 12th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PrintAndSum
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int num1 = int.Parse(Console.ReadLine());
  10.             int num2 = int.Parse(Console.ReadLine());
  11.             int sum = 0;
  12.  
  13.             for (int i = num1; i <= num2; i++)
  14.             {
  15.                 Console.Write($"{i} ");
  16.                 sum += i;
  17.             }
  18.            
  19.             Console.WriteLine($"\nSum: {sum}");
  20.         }
  21.     }
  22. }
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement