Methodological Instructions
Theme: User defined procedures and functions 2 lesson
Objective: 10.4.1.1 write a code in the programming language using functions and procedures
Assessment criteria
· Students understand and distinguish the definitions of functions and procedures in programming.
· Students can solve problems using functions and procedures
· Knows and can determine the clock speed
Basic Level:
Previous 1 lesson of this topic
Key words and phrases:
Subprogram, function, procedure, formal and actual parameters, global and local variables
Function - part of the program that has...
Method is a function that is...
Function is used for…
Procedure is used for...
I. Practice.
1. Write a program create a user define function.
Expected Output :
Welcome Friends!
Have a nice day!
2. Write a program to create a user define function with parameters.
Test Data :
Please input a name : John
Expected Output :
Welcome friend John !
Have a nice day!
3. Write a program to create a function for the sum of two numbers.
Test Data :
Enter a number: 15
Enter another number: 16
Expected Output :
The sum of two numbers is : 31
4. Write a program to create a function to input a string and count number of spaces are in the string. Go to the editor
Test Data :
Please input a string : This is a test string.
Expected Output :
"This is a test string." contains 4 spaces
5. Write a program to calculate the sum of elements in an array
Test Data :
Input 5 elements in the array :
element - 0 : 5
element - 1 : 7
element - 2 : 3
element - 3 : 2
element - 4 : 9
Expected Output :
The sum of the elements of the array is 26
6. Write a program to create a function to swap the values of two integer numbers.
Test Data :
Enter a number: 5
Enter another number: 6
Expected Output :
Now the 1st number is : 6 , and the 2nd number is : 5
7. Write a program to create a function to calculate the result of raising an integer number to another.
Test Data :
Input Base number: 3
Input the Exponent : 2
Expected Output :
So, the number 3 ^ (to the power) 2 = 9
8. Write a program to create a function to display the n number Fibonacci sequence.
Test Data :
Input number of Fibonacci Series : 5
Expected Output :
The Fibonacci series of 5 numbers is :
0 1 1 2 3
9. Write a program to create a function to check whether a number is prime or not.
Test Data :
Input a number : 31
Expected Output :
31 is a prime number
10. Write a program to create a function to calculate the sum of the individual digits of a given number.
Test Data :
Enter a number: 1234
Expected Output :
The sum of the digits of the number 1234 is : 10
11. Write a program to create a recursive function to find the factorial of a given number.
Test Data :
Enter a number: 5
Expected Output :
The factorial of 5! is 120
12. Write a program to create a recursive function to calculate the Fibonacci number of a specific term.
Test Data :
Enter a number: 10
Expected Output :
The Fibonacci of 10 th term is 55
Visual Aids and Materials.
1. Slides
2. http://physics.herzen.spb.ru/library/03/01/pp/TPHelp/subroutines.htm
3. https://en.wikibooks.org/wiki/A-level_Computing/AQA/Paper_1/Fundamentals_of_programming/Subroutines_(functions_and_procedures)
4. Procedures and functions of working with strings: http://pas1.ru/stringfunction
5. http://purecodecpp.com/archives/920
6. https://www.bbc.com/bitesize/guides/z9hykqt/revision/1
7. https://www.advanced-ict.info/programming/functions.html
8. Tasks with solutions https://www.w3resource.com/csharp-exercises/function/index.php
9. Скачано с www.znanio.ru
© ООО «Знанио»
С вами с 2009 года.