Functions in C | Chapter 7 | Class 10 Computer Science 571(NCERT) Question and Answer | Class 10 Computer Science 571(NCERT) Question and Answer Solution English Medium |
Functions in C
Chapter 7
Exercise
1. What is a global variable in C? Why do we need such a variable?
(āĻি-āϤ āĻāĻ āĻোāϞāĻীāϝ় āĻĒā§°িā§ąā§°্āϤāύāĻļীāϞ āĻি? āĻāĻŽাāĻ āĻāύে āĻĒā§°িā§ąā§°্āϤāύāĻļীāϞ⧰ āĻিāϝ় āĻĒ্ā§°āϝ়োāĻāύ?)
Ans: A variable defined outside the range of all functions is known as a global variable in C. Global variables have a global range, so these variables can be input and modified by any function, structure, or any category C.
Variables are used to store references and information manipulated in a computer program. It also provides a way to label data with descriptive names so that our programs are readers and we can understand more clearly.
(āϏāĻāϞো āĻĢাংāĻāύ⧰ āĻĒā§°িāϏ⧰⧰ āĻŦাāĻšিā§°āϤ āύিā§°্āϧাā§°িāϤ āĻĒā§°িā§ąā§°্āϤāύāĻļীāϞ āĻāĻাāĻ āĻি-āϤ āĻāĻ āĻোāϞāĻীāϝ় āĻāϞāĻ āĻšিāĻাāĻĒে āĻāύা āϝাāϝ়। āĻ্āϞোāĻŦেāϞ āĻেā§°িāϝ়েāĻŦāϞāĻŦোā§°ā§° āĻāĻ āĻোāϞāĻীāϝ় āĻĒā§°িāϏ⧰ āĻĨাāĻে, āϏেāϝ়েāĻšে āĻāĻ āĻāϞāĻāĻŦোā§° āϝিāĻোāύো āĻĢাংāĻāύ, āĻাঁāĻĨāύি āĻŦা āϝিāĻোāύো āĻļ্ā§°েāĻŖী āĻি-ā§° āĻĻ্āĻŦাā§°া āĻāύāĻĒুāĻ āĻā§°ু āϏংāĻļোāϧāύ āĻā§°িāĻŦ āĻĒাā§°ি।
āĻāĻŽ্āĻĒিāĻāĻাā§° āĻĒ্ā§°'āĻ্ā§°াāĻŽ āĻāĻাāϤ āĻĒ্ā§°āϏংāĻ āĻā§°ু āϤāĻĨ্āϝ āϏংā§°āĻ্āώāĻŖ āĻā§°িāĻŦāϞৈ āĻāϞāĻāĻŦ্āĻ¯ā§ąāĻšাā§° āĻā§°া āĻšāϝ়। āĻ āĻŦā§°্āĻŖāύাāĻŽূāϞāĻ āύাāĻŽā§° āϏৈāϤে āĻĄাāĻা āϞেāĻŦেāϞ āĻā§°াā§° āĻāĻা āĻāĻĒাāϝ়āĻ āĻĒ্ā§°āĻĻাāύ āĻā§°ে āϝাāϤে āĻāĻŽাā§° āĻাā§°্āϝāϏূāĻীāĻŦোā§° āĻĒāĻĸ়ুā§ąৈ āĻšāϝ় āĻā§°ু āĻāĻŽি āĻ āϧিāĻ āϏ্āĻĒāώ্āĻāĻাā§ąে āĻŦুāĻি āĻĒাāĻঁ।)
2. Write the syntax of a function declaration. The name of the function is calculateAge (). The function accepts the current year and birth year of a person. The function returns the age of the person.
(āĻĢাংāĻāύ āĻোāώāĻŖা āĻāĻাā§° āĻŦাāĻ্āϝāĻŦিāύ্āϝাāϏ āϞিāĻāĻ। āĻĢাংāĻāύ⧰ āύাāĻŽ āĻšৈāĻে āĻāĻŖāύা āĻā§°া()। āĻĢাংāĻāύāĻোā§ąে āĻāĻāύ āĻŦ্āϝāĻ্āϤিā§° āĻāϞিāϤ āĻŦā§°্āώ āĻā§°ু āĻāύ্āĻŽ āĻŦā§°্āώ āĻ্ā§°āĻšāĻŖ āĻā§°ে। āĻĢাংāĻāύāĻোā§ąে āĻŦ্āϝāĻ্āϤিāĻāύ⧰ āĻŦāϝ়āϏ āĻূā§°াāĻ āĻĻিāϝ়ে।)
Ans: A feature announcement tells the compiler about the function name and how to switch the function. The actual body of functions can be defined separately. maximum (Int., Inc.); A feature declaration is required when defining the function in one source file and when calling the function to another file.
Take the difference between the current year and the year of their birth: year = present year - year of birth.
Take the difference between the present month and the month of their birth: month = current month - month of birth.
The next dated function calculates a person's age.
(āĻāĻা āĻĢিāĻাā§° āĻোāώāĻŖাāĻ āĻāĻŽ্āĻĒাāĻāϞাā§°āĻ āĻĢাংāĻāύ āύাāĻŽ āĻā§°ু āĻĢাংāĻāύāĻো āĻেāύেāĻĻā§°ে āϏāϞāύি āĻā§°িāĻŦ āϞাāĻে āϏেāĻ āĻŦিāώāϝ়ে āĻāϝ়। āĻĢাংāĻāύāĻŦোā§°ā§° āĻĒ্ā§°āĻৃāϤ āĻļā§°ীā§°āĻো āĻĒৃāĻĨāĻে āϏংāĻ্āĻাāϝ়িāϤ āĻā§°িāĻŦ āĻĒাā§°ি। āϏ⧰্āĻŦাāϧিāĻ (āĻāĻŖ্āĻ,āĻāύāĻ.); āĻāĻা āĻā§āϏ āĻĢাāĻāϞāϤ āĻĢাংāĻāύāĻো āύিā§°্āϧাā§°āĻŖ āĻā§°োঁāϤে āĻā§°ু āĻĢাংāĻāύāĻো āĻāύ āĻāĻা āĻĢাāĻāϞāϞৈ āĻāϞ āĻā§°োঁāϤে āĻāĻা āĻĢিāĻাā§° āĻোāώāĻŖাā§° āĻĒ্ā§°āϝ়োāĻāύ।
āĻāϞিāϤ āĻŦā§°্āώ āĻā§°ু āϤেāĻঁāϞোāĻā§° āĻāύ্āĻŽā§° āĻŦāĻā§°ā§° āĻŽাāĻā§° āĻĒাā§°্āĻĨāĻ্āϝ āϞāĻঁāĻ: āĻŦāĻā§° = āĻŦā§°্āϤāĻŽাāύ āĻŦā§°্āώ - āĻāύ্āĻŽāĻŦā§°্āώ।
āĻŦā§°্āϤāĻŽাāύ āĻŽাāĻš āĻā§°ু āϤেāĻঁāϞোāĻā§° āĻāύ্āĻŽ āĻŽাāĻšā§° āĻŽাāĻā§° āĻĒাā§°্āĻĨāĻ্āϝ āϞāĻঁāĻ: āĻŽাāĻš = āĻāϞিāϤ āĻŽাāĻš - āĻāύ্āĻŽ āĻŽাāĻš।
āĻĒā§°ā§ąā§°্āϤী āϤাā§°িāĻā§° āĻĢাংāĻāύে āĻāĻāύ āĻŦ্āϝāĻ্āϤিā§° āĻŦāϝ়āϏ āĻāĻŖāύা āĻā§°ে।)
3. Write the code segment for the function definition of the above function calculateAge.
(āĻāĻĒā§°োāĻ্āϤ āĻĢাংāĻāύ āĻāĻŖāύাā§° āĻĢাংāĻāύ āϏংāĻ্āĻাā§° āĻŦাāĻŦে āĻোāĻĄ āĻāĻŖ্āĻĄāϞিāĻāĻ।)
Ans: Act with logic and returned values. This function has arguments and returns a value: ...
Works with logic and without return value. ...
Act without logic and with returned values. ...
Act without logic and without returned values.
Most usage guides will say that you want to talk about two people or things ('sitting between John and Carol') and more than two people or things ('students are talking among themselves').
(āϝুāĻ্āϤি āĻā§°ু āĻূā§°াāĻ āĻĻিāϝ়া āĻŽূāϞ্āϝāĻŦোāϧ⧰ āϏৈāϤে āĻাāĻŽ āĻā§°āĻ। āĻāĻ āĻĢাংāĻāύ⧰ āϤ⧰্āĻ āĻāĻে āĻā§°ু āĻāĻা āĻŽূāϞ্āϝ āĻূā§°াāĻ āĻĻিāϝ়ে: ...
āϝুāĻ্āϤিā§° āϏৈāϤে āĻā§°ু āĻূā§°াāĻ āĻĻিāϝ়া āĻŽূāϞ্āϝ āĻ āĻŦিāĻšāύে āĻাāĻŽ āĻā§°ে। ...
āϝুāĻ্āϤি āĻ āĻŦিāĻšāύে āĻā§°ু āĻূā§°াāĻ āĻĻিāϝ়া āĻŽূāϞ্āϝ⧰ āϏৈāϤে āĻাāĻŽ āĻā§°āĻ। ...
āϝুāĻ্āϤি āĻ āĻŦিāĻšāύে āĻā§°ু āĻূā§°াāĻ āĻĻিāϝ়া āĻŽূāϞ্āϝāĻ āĻŦিāĻšāύে āĻাāĻŽ āĻā§°āĻ।
āĻŦেāĻিāĻাāĻ āĻŦ্āĻ¯ā§ąāĻšাā§° āĻাāĻāĻĄে āĻ'āĻŦ āϝে āĻāĻĒুāύি āĻĻুāĻāύ āĻŦ্āϝāĻ্āϤি āĻŦা āĻŦāϏ্āϤুā§° āĻŦিāώāϝ়ে āĻāĻĨা āĻĒাāϤিāĻŦ āĻŦিāĻাā§°ে ('āĻāύ āĻā§°ু āĻেā§°āϞ⧰ āĻŽাāĻāϤ āĻŦāĻšিāĻāĻে') āĻā§°ু āĻĻুāĻাāϤāĻৈ āĻ āϧিāĻ āϞোāĻ āĻŦা āĻŦāϏ্āϤুā§° āĻŦিāώāϝ়ে ('āĻļিāĻ্āώাā§°্āĻĨীāϏāĻāϞে āύিāĻā§° āĻŽাāĻāϤ āĻāĻĨা āĻĒাāϤি āĻāĻে')।
4. What are different types of functions in C ? Differentiate among them.
(āĻি-āϤ āĻŦিāĻিāύ্āύ āĻĒ্ā§°āĻাā§°ā§° āĻĢাংāĻāύ āĻি? āϏেāĻāĻŦোā§°ā§° āĻŽাāĻāϤ āĻĒাā§°্āĻĨāĻ্āϝ āĻā§°āĻ।)
Ans:
5. Differentiate between caller and callee functions, write a small C progarm and identify. the caller and callee function in it.
(āĻāϞাā§° āĻā§°ু āĻেāϞি āĻĢাংāĻāύ⧰ āĻŽাāĻāϤ āĻĒাā§°্āĻĨāĻ্āϝ āĻā§°āĻ, āϏ⧰ু āĻি āĻĒ্ā§°āĻাā§°্āĻŽ āĻāĻা āϞিāĻāĻ āĻā§°ু āĻিāύাāĻ্āϤ āĻā§°āĻ। āĻĢোāύ āĻā§°া āĻā§°ু āĻāϞিāϝ়ে āĻāϝ়াāϤ āĻাāĻŽ āĻā§°ে।)
Ans:
6. When do we call a function user-defined? Is printf() a user-defined function? Justify.
(āĻāĻŽি āĻেāϤিāϝ়া āĻĢাংāĻāύ āĻāĻাāĻ āĻŦ্āĻ¯ā§ąāĻšাā§°āĻাā§°ী-āύিā§°্āϧাā§°িāϤ āĻŦুāϞি āĻāĻঁ? āĻĒ্ā§°িāĻŖ্āĻāĻĢ() āĻŦ্āĻ¯ā§ąāĻšাā§°āĻাā§°ী-āύিā§°্āϧাā§°িāϤ āĻĢাংāĻāύ āύেāĻি? āύ্āϝাāϝ়āϏāĻ্āĻāϤ।)
Ans:
7. Can we have two functions with the same name but with different numbers of parameters in a single C program? Write a simple C program to justify your answer.
(āĻāĻŽি āĻāĻে āύাāĻŽā§° āĻĻুāĻা āĻĢাংāĻāύ āĻā§°িāĻŦ āĻĒাā§°োঁ āύেāĻি āĻিāύ্āϤু āĻāĻা āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽāϤ āĻŦিāĻিāύ্āύ āϏংāĻ্āϝāĻ āĻĒ্ā§°াāĻāϞ⧰ āϏৈāϤে? āĻāĻĒোāύাā§° āĻāϤ্āϤ⧰āĻো āύ্āϝাāϝ়āϏāĻ্āĻāϤ āĻā§°িāĻŦāϞৈ āĻāĻা āϏ⧰āϞ āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽ āϞিāĻāĻ।)
Ans:
8. What are different components of a function? Show with a complete C program.
(āĻĢাংāĻāύ āĻāĻাā§° āĻŦিāĻিāύ্āύ āĻāĻĒাāĻĻাāύāĻŦোā§° āĻি? āĻāĻা āϏāĻŽ্āĻĒূā§°্āĻŖ āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽā§° āϏৈāϤে āĻĒ্ā§°āĻĻā§°্āĻļāύ āĻā§°āĻ।)
Ans:
9. Define recursive function. Can we use a recursive function to solve all kinds of problems?
( āĻĒুāύ⧰াāĻŦৃāϤ্āϤিāĻŽূāϞāĻ āĻĢাংāĻāύ āύিā§°্āϧাā§°āĻŖ āĻā§°āĻ। āĻāĻŽি āϏāĻāϞো āϧ⧰āĻŖā§° āϏāĻŽāϏ্āϝা āϏāĻŽাāϧাāύ āĻā§°িāĻŦāϞৈ āĻāĻা āĻĒুāύ⧰াāĻŦৃāϤ্āϤিāĻŽূāϞāĻ āĻĢাংāĻāύ āĻŦ্āĻ¯ā§ąāĻšাā§° āĻā§°িāĻŦ āĻĒাā§°োঁāύে?)
Ans:
10. Consider the below code and list all the syntax errors.
(āϤāϞ⧰ āĻোāĻĄāĻো āĻŦিāĻŦেāĻāύা āĻā§°āĻ āĻā§°ু āϏāĻāϞো āĻŦাāĻ্āϝāĻŦিāύ্āϝাāϏ āϤ্ā§°ুāĻি āϤাāϞিāĻাāĻুāĻ্āϤ āĻā§°āĻ।)
Ans:
11. Consider the code segment below and find out the output if the user enters 5 from the keyboard when asked for.
(āϤāϞ⧰ āĻোāĻĄ āĻāĻŖ্āĻĄāĻো āĻŦিāĻŦেāĻāύা āĻā§°āĻ āĻā§°ু āϝāĻĻি āĻŦ্āĻ¯ā§ąāĻšাā§°āĻাā§°ীāϝ়ে āĻŦিāĻাā§°িāϞে āĻীāĻŦā§°্āĻĄā§° āĻĒā§°া 5 āĻĒ্ā§°āĻŦিāώ্āĻ āĻā§°ে āϤেāύ্āϤে āĻāĻāĻāĻĒুāĻāĻো āĻŦিāĻাā§°ি āĻāϞিāϝ়াāĻāĻ।)
Ans:
12. Write a C program and define a function square() that accepts a number as the parameter and returns the square of that number as output.
(āĻāĻা āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽ āϞিāĻāĻ āĻā§°ু āĻāĻা āĻĢাংāĻāύ āĻŦā§°্āĻ () āύিā§°্āϧাā§°āĻŖ āĻā§°āĻ āϝি āĻāĻা āϏংāĻ্āϝাāĻ āĻĒ্ā§°াāĻāϞ āĻšিāĻাāĻĒে āĻ্ā§°āĻšāĻŖ āĻā§°ে āĻā§°ু āϏেāĻ āϏংāĻ্āϝাā§° āĻŦā§°্āĻāĻো āĻāĻāĻāĻĒুāĻ āĻšিāĻাāĻĒে āĻূā§°াāĻ āĻĻিāϝ়ে।)
Ans:
13. Write a C program and define a function search () that searches an element in an array and returns the index of the element.
(āĻāĻা āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽ āϞিāĻāĻ āĻā§°ু āĻāĻা āĻĢাংāĻāύ āϏāύ্āϧাāύ () āύিā§°্āϧাā§°āĻŖ āĻā§°āĻ āϝি āĻāĻা āĻā§°েāϤ āĻāĻা āĻāĻĒাāĻĻাāύ āĻ āύুāϏāύ্āϧাāύ āĻā§°ে āĻā§°ু āĻāĻĒাāĻĻাāύāĻোā§° āϏূāĻী āĻূā§°াāĻ āĻĻিāϝ়ে।)
Ans:
14. Write a C program and define a recursive function to find the summation of first N natural numbers.
(āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽ āĻāĻা āϞিāĻāĻ āĻā§°ু āĻĒ্ā§°āĻĨāĻŽ āĻāύ āĻĒ্ā§°াāĻৃāϤিāĻ āϏংāĻ্āϝাāĻŦোā§°ā§° āϏংāĻ্āώিāĻĒ্āϤāĻā§°āĻŖ āĻŦিāĻাā§°িāĻŦāϞৈ āĻāĻা āĻĒুāύ⧰াāĻŦৃāϤ্āϤিāĻŽূāϞāĻ āĻĢাংāĻāύ āύিā§°্āϧাā§°āĻŖ āĻā§°āĻ।)
Ans:
15. Write a C program and define a function add() that accepts three integers. These integers indicate indices of an integer array. The function returns the summation of the elements stored in those indices.
(āĻāĻা āĻি āĻĒ্ā§°'āĻ্ā§°াāĻŽ āϞিāĻāĻ āĻā§°ু āϤিāύিāĻা āĻĒূā§°্āĻŖāϏংāĻ্āϝা āĻ্ā§°āĻšāĻŖ āĻā§°া āĻĢাংāĻāύ āϝোāĻ () āύিā§°্āϧাā§°āĻŖ āĻā§°āĻ। āĻāĻ āĻĒূā§°্āĻŖāϏংāĻ্āϝাāĻŦোā§°ে āĻāĻা āĻāĻŖ্āĻেāĻাā§° āĻā§°েā§° āϏূāĻāĻ āϏূāĻাāϝ়। āĻĢাংāĻāύāĻোā§ąে āϏেāĻ āϏূāĻāĻāĻŦোā§°āϤ āϏāĻ্āĻিāϤ āĻāĻĒাāĻĻাāύāĻŦোā§°ā§° āϏাā§°াংāĻļ āĻূā§°াāĻ āĻĻিāϝ়ে।)
For example, if we call the function add( 0, 2, 5), the function will return 24. The output is formed by 7+ 8+ 9 because elements at indices 0, 2 and 5 are 7, 8 and 9 respectively.
(āĻāĻĻাāĻšā§°āĻŖ āϏ্āĻŦā§°ূāĻĒে, āϝāĻĻি āĻāĻŽি āĻĢাংāĻāύāĻোāĻ āϝোāĻ āĻĻিāĻঁ(0, 2, 5) āĻāϞ āĻā§°োঁ, āĻĢাংāĻāύāĻো 24 āĻূā§°াāĻ āĻĒাāĻŦ। āĻāĻāĻāĻĒুāĻ 7+ 8+ 9 ā§° āĻĻ্āĻŦাā§°া āĻāĻ āύ āĻā§°া āĻšāϝ় āĻিāϝ়āύো āϏূāĻāĻ 0, 2 āĻā§°ু 5-āϤ āĻāĻĒাāĻĻাāύāĻŦোā§° āĻ্ā§°āĻŽাāύ্āĻŦāϝ়ে 7, 8 āĻā§°ু 9 āĻšāϝ়।)
Ans:
Type & Assamese Translate : Himashree Bora.
Post ID : DABP005297