Programming1 Week1 Exercises
Programming1 Week1 Exercises
3.
a b c
a. Choose Language: C#
b. Choose Platform: Windows
c. Choose Project type: Console
d. Select Console App
d
e. Click button Next
4.
a. Enter as Project name: ‘assignment1’.
b. Choose a suitable location for your project
files a
c. Enter as Solution name:
‘IntroductionProgramming1’
d. Click button Next
b
5.
a. Select framework: .NET 6.0
b. Check ‘Do not use top-level statements’
c. Click button Create
(September 2022)
Programming 1 – Week 1 - Exercises
Exercise 1 - input/output
In this exercise we will create a simple program that has some input and output.
(September 2022)
Programming 1 – Week 1 - Exercises
Exercise 2 - conversion
In this exercise we take a look at converting the data type of one variable into another data type, also known as a
conversion.
1.
a. Right-click on Solution
‘IntroductionProgramming1’
b. Click on Add
c. Click on New Project…
2.
a. Choose again ‘Console App’
b. Click on button Next
3.
a. Enter as Project name: assignment2
b. Click on button Next
4.
a. Select framework: .NET 6.0
b. Check ‘Do not use top-level
statements’
c. Click button Create
(September 2022)
Programming 1 – Week 1 - Exercises
The new project will not do anything yet, since assignment1 is still the ‘startup project’. We will have to change this.
5.
a. Right-click on assignment2
b. Click on Set as StartUp Project
(September 2022)
Programming 1 – Week 1 - Exercises
(September 2022)
Programming 1 – Week 1 - Exercises
Exercise 5 – Mathematics
On the exam of Mathematics one of the first questions is often to add four positive integers between 100 and 10000. In
C# you can generate a random number using:
Random rnd = new Random();
And then declare a random variable using for example
int number1 = rnd.Next(101, 10000);
• Write a program that will show four numbers between 101 and 10000, then asks to add these up, and checks
the result.
(September 2022)