Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Lesson1 / 20

    Module 1 · First programs: see what each line does · Lesson 1 of 20

    Your first program: make the computer say something

    Can you make the computer print your own study plan? Start with three lines, then change one message and run it again. No programming experience is required.

    Get one small program running

    Install the .NET 10 SDK for your computer from the official download page, choosing the SDK section. C# is the language; the SDK supplies the tools that build and run it. Use a text editor such as Visual Studio Code to edit the file.

    1. Check the tool. Open a terminal and run:

    Text
    dotnet --list-sdks

    A version beginning with 10.0 should be listed. If dotnet cannot be found just after installation, reopen the terminal and try again.

    2. Create your practice folder. From a folder where you keep projects, run:

    Text
    dotnet new console --framework net10.0 -o StudyPlanner
    cd StudyPlanner

    You now have a StudyPlanner folder containing a project file and Program.cs.

    3. Make your first edit. Open Program.cs. Replace all its contents with the three-line printing program below and save. Each later C# block is also an independent replacement program unless a lesson explicitly says otherwise. Run the programs locally; this page has no in-page compiler.

    Predict, then run

    Read the instructions from top to bottom. Write the three output lines on paper before running.

    C#
    using System;
    
    Console.WriteLine("Study Planner");
    Console.WriteLine("Read C# for 30 minutes.");
    Console.WriteLine("One small step today.");

    Which output comes first?

    A Read C# for 30 minutes.
    B Study Planner
    C One small step today.
    D All three appear on one line.
    Show answer

    Correct answer: B

    The first WriteLine instruction prints Study Planner, followed by a line break.

    Option A: That is the second instruction.

    Option C: That instruction appears last.

    Option D: Each WriteLine call ends its output with a line break.

    Hint: Follow the statements from the top.

    Now run the saved program from the StudyPlanner folder:

    Text
    dotnet run

    Your program’s output should be:

    Text
    Study Planner
    Read C# for 30 minutes.
    One small step today.

    The first line, using System;, lets us write Console instead of System.Console. System is a namespace: a group of related type names. The statements below it do the printing.

    Console.WriteLine asks .NET to write a line of text. The text between double quotes is a string literal. The quotes mark its boundary; they are not printed. Parentheses hold the information passed to WriteLine. The semicolon ends this instruction. C# names are case-sensitive, so copy Console and WriteLine with the shown capitals.

    See the stages

    Text
    Edit Program.cs → Save → Build → Run → Read the output
         instructions          check/translate      execute

    Saving records your edit. Building checks and translates it. Running executes the application. The dotnet run command normally builds as needed before starting. To check compilation without starting the app, use dotnet build. A successful build tells you the code follows the language rules; you still need to check whether its output meets your goal.

    You save a changed message, but do not run the program. What happens in the old terminal output?

    A It changes immediately.
    B The file is deleted.
    C The previous output stays as it was.
    D The computer automatically asks for a name.
    Show answer

    Correct answer: C

    Saving changes the source file. Previously printed output does not update itself.

    Option A: You must run the changed program to produce new output.

    Option B: Saving does not delete the file.

    Option D: This program contains no input instruction.

    Change it yourself

    Change the duration to 45 minutes and make the last line say Then take a short break. Save, predict all three lines, then run. Compare your attempt with this complete solution:

    C#
    using System;
    
    Console.WriteLine("Study Planner");
    Console.WriteLine("Read C# for 45 minutes.");
    Console.WriteLine("Then take a short break.");

    After that change, what is the second output line?

    A Read C# for 45 minutes.
    B 45
    C Then take a short break.
    D Read C# for 30 minutes.
    Show answer

    Correct answer: A

    The entire text inside the second pair of quotes is printed.

    Option B: The instruction prints a sentence, not only the number.

    Option C: That is the third line.

    Option D: The changed program now contains 45.

    If compilation fails, read the first relevant diagnostic and its line number. Check missing quotes, parentheses and semicolons. If the old message appears, confirm that you saved Program.cs and ran from this project’s folder.

    Explain back: What is the difference between saving, building and running? Point to the instruction that produces each output line before moving on.

    References: Microsoft — create a console app, dotnet new.

    Quick reference

    • C# is the language; the .NET SDK provides build and run tools.
    • Edit Program.cs, save it, then run dotnet run in the project folder.
    • Console.WriteLine prints a value followed by a line break.
    • Text literals use double quotes; the quotes are not printed.
    • Read output in the order the instructions execute.
    Sign in to mark lessons done and keep your place in the course.Sign in

    TechInterviewNotes Editorial Team · Updated 27 Oct 2026 ·