Methodological Instructions
Theme: User functions and procedures
Aim: write code in programming language using functions and procedures
Assessment criteria
Knowledge
· Know what is function
· Know what is procedure
Understanding
· Describes the difference between function and procedure
Application
· Write code using functions
· Write code using procedures
Analysis
· Analyze function code
Key words and phrases:
Void, IntelliSense, procedure, function, bracket, return value
Useful expressions for dialogs and letters:
Well, there are cases when we use returning … .
For example, the IntelliSense is of considerable support when … .
Obviously, the functions and procedures are used to make … .
Theory
A function allows you to encapsulate a piece of code and call it from other parts of your code.
If you’re familiar with Visual Basic or Pascal, notice that C# does not use different keywords to distinguish between a method that returns a value (a function) and a method that does not return a value (a procedure or subroutine).
You must always specify either a return type or void
public static void replacesign (int[] numbers, int
number)
{
for (int i=0; i<numbers.Length; i++) {
if (numbers[i] == number) {
numbers[i] = -numbers[i];
}
}
}
static void Main()
{
int[] numbers = {12, 5, 7, 83, 5, 8, 5};
replacesign (numbers, 5);
for(int i=0; i<numbers.Length; i++)
{
Console.WriteLine(numbers[i]);
}
}
П. Questions for self-assessment.
1) What is the difference between procedure and function?
2) How to call a procedure or function?
3) How to use procedure or function?
Visual Aids and Materials links.
1. Slides
2. https://csharp.net-tutorials.com/basics/functions/
3. https://docs.microsoft.com/ru-ru/dotnet/csharp/language-reference/keywords/value-types
4. https://poisk-ru.ru/s30898t9.html
Students' Practical Activities:
Students must be able:
· Write code using functions
· Write code using procedures
Скачано с www.znanio.ru
Материалы на данной страницы взяты из открытых источников либо размещены пользователем в соответствии с договором-офертой сайта. Вы можете сообщить о нарушении.