String handling operations in a programming language

EasyMedium
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
Question 38
Easy

A C# program is being written to validate flight codes. Figure 1 shows the code for flight code length check and input.

Figure 1

1  int retryCount = 0;
2  Console.Write("Enter your flight code: ");
3  string flightCode = Console.ReadLine();
4  while (flightCode.Length > 8) {
5      string errorMessage = " exceeds maximum length";
6      Console.Write(errorMessage);
7      flightCode = Console.ReadLine();
8  }
9  Console.Write("Flight code verified.");

Rewrite line 5 in Figure 1 to concatenate the flight code with the string " exceeds maximum length", and store the result in the variable errorMessage.

Your answer must be written in C#.

[2]

String handling operations in a programming language Questions

  1. GCSE
  2. /Computer Science
  3. /String handling operations in a programming language