Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- { // the range [x,y] closed
- int x = Convert.ToInt32(Console.ReadLine());
- int y = Convert.ToInt32(Console.ReadLine());
- int sum =0; // will carry the sum :3 declared out side loop scoop with value = 0
- int temp;
- //swap
- if (x > y) {
- temp = x;
- x = y;
- y = temp;
- }
- while (x <= y) { //removed 5 we 7atet y as max range
- //simple sum
- sum += x;
- // the increment to make the loop end
- x++;
- }
- //the answer out side the loop
- Console.WriteLine("the sum is : {0}", sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement