Advertisement
dragonbs

Print And Sum

Feb 2nd, 2023
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.24 KB | None | 0 0
  1. int start = int.Parse(Console.ReadLine());
  2. int end = int.Parse(Console.ReadLine());
  3.  
  4. int sum = 0;
  5.  
  6. for (int i = start; i <= end; i++)
  7. {
  8.     Console.Write($"{i} ");
  9.     sum += i;
  10. }
  11. Console.WriteLine();
  12. Console.WriteLine($"Sum: {sum}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement