Functions


  1. Write a note on functions and its advantages. (Google it)

  2. What is the use of arguments/parameters.

  3. A water storage company manufactures cylindrical tanks of different sizes. To determine the storage capacity of a tank, the volume of the cylinder needs to be calculated using a user-defined function without arguments. The radius and height are entered through the keyboard, and the function calculates and displays the volume of the cylinder.

  4. A sports competition records the scores of two players. To identify the better performer, the higher score needs to be determined using a user-defined function without arguments. Two numbers are entered through the keyboard, and the function identifies and displays the greatest number.

  5. A security system uses special numeric codes for verification. Some codes remain exactly the same even when their digits are read from left to right or from right to left. A number is entered through the keyboard, and a user-defined function without arguments checks and displays whether the number satisfies this special property or not.

  6. A company stores the sales data of different branches in an array for analysis. To identify the branch with the highest sales, the largest element of the array needs to be determined using a user-defined function without arguments. The array elements are entered through the keyboard, and the function identifies and displays the greatest element.

  7. An engineering workshop designs different types of 3D containers for storage purposes. Some containers are cylindrical while others are cone-shaped. To estimate the capacity of each container, the dimensions are passed to user-defined functions with arguments. The functions calculate and display the volume of the cylinder and the cone based on the values entered through the keyboard inside main() function.

  8. A school organizes a quiz competition between two students and records their scores for comparison. To determine the winner, the scores are passed to a user-defined function with arguments, which identifies and displays the greater score among the two numbers entered through the keyboard.

  9. A digital lock system stores numeric access codes for security verification. To process the code in a different format, the entered number is passed as an argument to a user-defined function, which rearranges the digits from the last position to the first position and displays the final result on the screen.

  10. A selection committee evaluates three candidates based on their scores in a written test. To identify the best performer, the three scores are passed to a user-defined function with arguments, which compares them and returns the greatest value. The returned result to main() is then displayed on the screen as the highest score among the three numbers entered through the keyboard.

  11. A school examination system evaluates students based on their performance in three subjects. The marks of the three subjects are first passed to a user-defined function doTotal() which calculates and returns the total marks to the main() function. After that, the total marks are again passed from main() to another function doPer(), which calculates the percentage and returns the result. Finally, the main() function displays both the total and percentage of the student on the screen.

  12. . A bank wants to calculate the simple interest for customer deposits, but the function is not allowed to return any value. Instead, the values of principal (P), rate (R), and time (T) are passed to a function. The function calculates the simple interest. The main() function then displays the calculated simple interest on the screen without using any return value from the function.

  13. . A bank wants to calculate the simple interest for customer deposits, but the function is not allowed to return any value. Instead, the values of principal (P), rate (R), and time (T) are passed to a function. The function calculates the simple interest. The main() function then displays the calculated simple interest on the screen without using any return value from the function.

  14. A data processing system stores numeric values in two separate arrays for comparison and calculation purposes. To generate a combined result, both arrays are passed as arguments to a user-defined function. The function adds corresponding elements of the two arrays and stores the result in a third array. Show result inside user defined function.

  15. Write a note on recursion and its advantages.

  16. Write diff. between Local and Global variables.