Back

Activity 1.1 Hello World!

divider

Introduction

Activity 1.1

Hello World!

Topics

  • Output
  • Console Output
  • Comments

Output

Demo

Call Console.WriteLine(). Write a message of your choice.

Program.cs
Console.WriteLine("Hello World!");
Output
Hello World!

'F' → Fullscreen

Objectives

  • icon Writing and executing code
  • icon Displaying console output
  • icon Debugging potential syntax errors
  • icon Reading comments
divider

Activity Tasks

  • icon Create a new C# project named 1-1-Output.
  • icon Complete each task individually.

Task 1: Write and Test

  • icon Write each line of code from the section making sure to stay within the main method.
  • icon Run and test your project to ensure it executes as intended.
Program.cs
Console.WriteLine("Welcome to the Skynest Nexus.");
Console.WriteLine("This class is taught by Mr. Mortimer");
Console.WriteLine();
// Stop and run your code

Task 2: Add More Code

  • icon Write the additional sections of output under your current print statements.
  • icon Run and test your project to ensure it executes as intended.
Program.cs
Console.WriteLine("Welcome to the Skynest Nexus.");
Console.WriteLine("This class is taught by Mr. Mortimer");
Console.WriteLine();
Console.WriteLine("What is the answer to life, the universe, and everything?");
Console.WriteLine("The answer is 42.");
Console.WriteLine();
Console.WriteLine("Sally sells seashells by the seashore.");
Console.WriteLine("Sally wants to invite you to invest in a money making opportunity.");
Console.WriteLine();
Console.WriteLine("If you start to feel overwhelmed, just remember:");
Console.WriteLine("Mortimers don't quit, we get fired!");
// Stop and run your code

Task 3: Add Space

  • icon Add an additional blank print statement at the end of each section to increase the spacing between the sections.
  • icon Run and test your project to ensure it executes as intended.

Task 4: Write a Custom Section

  • icon Output a three-line paragraph of your choice somewhere in the program. Keep it school appropriate.
  • icon Run and test your project to ensure it executes as intended.

Task 5: Write Comments

  • icon Write the following comments to document and modify the code.
    • icon Disable the line of code that displays the message 'The answer is 42.' by placing a single-line comment at the beginning of the line.
    • icon Write a comment at the end of a blank print statement that states 'Displays a blank line'.
  • icon Run and test your project to ensure it executes as intended.
divider

Reflection Questions

  1. What is the primary function of Console.WriteLine()? How does it relate to the idea of a program "speaking" to a user?
  2. Imagine you typed Cosnol.WriteLine() by mistake. What do you think would happen when you try to run your program? Why is correct spelling so important in programming?
  3. What was the most challenging part of writing your first line of code?
divider

Submission

Submit your activity and reflection answers to the appropriate dropbox.

Activity Complete