Questions
Questions
- Open Visual Studio and create a new project for the Hello World application
-
Enter the source code from the "Hello World" example:
-
Compile and run
- Enhance the program to store your name in two variables, one for your first name and the other your last name
- Print your name to the screen using these variables using each of the approaches suggested above. Compile and run your program
-
Study the following program, and answer the questions below:
- What does the program do?
- What does
Console.ReadLine()
do? - The variables,
length
,width
etc are preceded by the keywordint
. What is the purpose ofint
in this context? Convert.ToInt32
is easy to read as "Convert to a 32 bit integer", but why is this necessary here?- What is the meaning of
=
in this context? - The "Hello World" program used
Console.WriteLine()
, this program usesConsole.Write()
. What is the difference between them?
Create a new project for the program in question 5, enter the code, compile and run. Add a title to print to the screen and add comments to identify the following features of the source code:
- program header
- statement to include a C# namespace (library)
- variable declarations
- output statement
- input statement
- assignment statement
Additional Exercises
- Install Visual Studio Community Edition on a home computer
- Create a directory on your computer for your programming projects
- Set up a GitHub account
- Write a program to calculate the area of a triangle. (The formula is \(\frac{height \times base}{2}\))
- Follow the Microsoft "numbers in C#" tutorial