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