Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Tobo and Motch
- Hausaufgabe part 1
- */
- using System;
- ... autofill stuff
- ...
- namespace Aufgabe2Einmaleins
- {
- class Program
- {
- static void Main(string[] args)
- {
- // VARIABLEN
- int upper_boundary;
- int result;
- int counter;
- // READ VALUES AND CONVERT EM
- Console.Write("Pls enter upper range:)";
- upper_boundary = Convert.ToInt32(Console.ReadLine());
- //ACTUAL PROGRAM
- for (counter = 1; counter <= upper_boundary; counter +=2)
- {
- result += counter;
- }
- Console.WriteLine("The Calculated Result is " +result);
- Console.ReadKey();
- while (counter <= upper_boundary)
- {
- result += counter;
- counter += 2;
- }
- Console.WriteLine("The Calculated Result is " +result);
- Console.ReadKey();
- do
- {
- result += counter;
- counter += 2;
- }
- while (counter <= upper_boundary);
- Console.WriteLine("The Calculated Result is " +result);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement