Skip to content

1. Test zur Vorbereitung - Programmieren & Softwareentwicklung

Notifications You must be signed in to change notification settings

IxI-Enki/Probetest-pose-001

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

1. ProbeTest

Angabe:

1


[klick] für LÖSUNG:

Vollständige Antworten:

Nummer 1:

//  declare variables:
double x, y, z;
/* CHECK VARIABLES: */
//  test the three inputs against each other, if all three 
//    are different from another, the IF branch is executed:  
if ((x != z) && (x != y) && (y != z)) {
//  output the "TOLL" message
Console.Write("\n 3 verschiedene Werte!"); }
//  if two of the input numbers are identical, the ELSE branch is executed:
 else
  Console.Write("\n mind. 2 gleiche Werte!");

Nummer 2:

      double a, b, c, swap;       
      /* CHECK VRIABLES: */
      if (a < b) {     //  test a - b , if a is smaller -> swap 
        swap = a;
        a = b;
        b = swap; }
      if (a < c) {     //  test a - c , if a is smaller -> swap
        swap = a;
        a = c;
        c = swap; }    //  a now guaranteed to be the biggest number
      if (b < c) {     //  test b - c , if b is smaller -> swap
        swap = b;
        b = c;
        c = swap; }    //  c now guaranteed to be the smallest value
      /* OUTPUT: */
      Console.Write($"\n größter Wert: {a} " +
                    $"\n mittlerer Wert: {b}" +             
                    $"\n kleinster Wert: {c}");

Nummer 3:

      int days, month;

      switch (month)                       
      {
        case 1:    //  Jänner
        case 3:    //  März
        case 5:    //  Mai
        case 7:    //  Juli
        case 8:    //  August
        case 10:   //  Oktober
        case 12:   //  Dezember
          days = 31;
          break;
        case 4:    //  April  
        case 6:    //  Juni
        case 9:    //  September
        case 11:   //  November
          days = 30;
          break;
        case 2:    //  Februar
          days = 28;
          break;
        default:   // invalid input
          days = -1;
          break;
      }
      if (days == -1)
      {
        Console.Write("\n ungültige Eingabe! ");
      }
      else
        Console.WriteLine($"\n Der {month}. Monat hat {days}Tage. ");
    }

Nummer 4:

   a = a * b + 2 * c;

Nummer 5:

      int i, j;
      /* LOOP A: */
      i = 1; j = 1;   ///  start values
      do
      {
        i = i + j;
        j++;
        Console.Write($"\n i={i}  &  j={j} ");
      } while (i < 200);
      Console.Write("\n A terminierte");
      /* LOOP B: */
      i = 1; j = 20;   ///  start values
      while (i + j < 100)
      {
        i = i + 2;
        j--;
        Console.Write($"\n i:{i}  &  j:{j}  --> i+j:{i+j}");
      }
      Console.Write("\n B terminierte");

Nummer 6:

      int n, i = 1;
      /* CALCULATION: */
      while (n / 10 != 0)
      {
        i++;
        n = n / 10;
      }
      /* OUTPUT: */
      Console.Write($"\n Die Zahl hatte: {i}Stellen. ");    

handwritten:

[klick] für LÖSUNGSVORSCHLAG:
Das Einlesen und Ausgeben mit "Console.Write ... " von Variablen,
 kann beim Test ausgesparrt werden!  

Nummer 1 & 2:

2

Nummer 3:

3

Nummer 5 & 6:

4


About

1. Test zur Vorbereitung - Programmieren & Softwareentwicklung

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages