Advertisement
Guest User

oef36

a guest
Oct 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _36AbsoluteWaarde
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int getal1;
  14.             int getal2;
  15.             int verschil;
  16.             int max = 0;
  17.  
  18.             for (int i = 1; i <= 20; i=i+2)
  19.             {
  20.                 Console.Write("getal " + i +": ");
  21.                 getal1 = int.Parse(Console.ReadLine());
  22.                 Console.Write("getal " + (i+1) + ": ");
  23.                 getal2 = int.Parse(Console.ReadLine());
  24.                 verschil = Math.Abs((getal1 - getal2));
  25.  
  26.                 if (verschil > max)
  27.                 {
  28.                     max = verschil;
  29.                 }
  30.             }
  31.  
  32.            
  33.             Console.WriteLine("Het grootste absolute verschil van twee opvolgende getallen was: " + max);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement