Advertisement
kruemelmonster1337

AEW_HA_II_18.06.17

Jun 19th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. /*  
  2.     Tobo and Motch
  3.     Hausaufgabe part 1
  4. */
  5.  
  6. using System;
  7. ... autofill stuff
  8. ...
  9.  
  10. namespace Aufgabe2Einmaleins
  11. {
  12.     class Program
  13.     {
  14.        
  15.         static void Main(string[] args)
  16.         {
  17.            
  18.             // VARIABLEN
  19.             int upper_boundary;
  20.             int result;
  21.             int counter;
  22.            
  23.             // READ VALUES AND CONVERT EM
  24.             Console.Write("Pls enter upper range:)";
  25.             upper_boundary = Convert.ToInt32(Console.ReadLine());
  26.            
  27.             //ACTUAL PROGRAM
  28.             for (counter = 1; counter <= upper_boundary; counter +=2)
  29.            
  30.             {
  31.                 result += counter;
  32.             }
  33.                
  34.             Console.WriteLine("The Calculated Result is " +result);
  35.             Console.ReadKey();
  36.                
  37.             while (counter <= upper_boundary)
  38.             {
  39.                 result += counter;
  40.                 counter += 2;
  41.             }
  42.            
  43.             Console.WriteLine("The Calculated Result is " +result);
  44.             Console.ReadKey();
  45.            
  46.             do
  47.             {
  48.                 result += counter;
  49.                 counter += 2;
  50.             }
  51.             while (counter <= upper_boundary);
  52.            
  53.             Console.WriteLine("The Calculated Result is " +result);
  54.             Console.ReadKey();
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement