0% found this document useful (0 votes)
6 views

Function

The document provides examples of functions for various programming concepts: basic functions, functions with parameters and return values, multiple functions, recursive functions, functions with arrays, functions with file handling, functions with user-defined data types, functions with exception handling, functions with inheritance and polymorphism, and functions with database operations. For each concept, 5 examples of programs are given that demonstrate functions used to implement that programming concept.

Uploaded by

pp0386390
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Function

The document provides examples of functions for various programming concepts: basic functions, functions with parameters and return values, multiple functions, recursive functions, functions with arrays, functions with file handling, functions with user-defined data types, functions with exception handling, functions with inheritance and polymorphism, and functions with database operations. For each concept, 5 examples of programs are given that demonstrate functions used to implement that programming concept.

Uploaded by

pp0386390
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic Function Examples:

Program with a function to add two numbers.

Program with a function to find the maximum of two numbers.

Program with a function to check if a number is even

.Program with a function to calculate the factorial of a number

.Program with a function to print a given message.

Function with Parameters and Return Values:

Program with a function to calculate the area of a rectangle.


Program with a function to find the square of a number.

Program with a function to concatenate two strings

.Program with a function to check if a string is a palindrome

.Program with a function to calculate the sum of an array of numbers.

Multiple Functions:

Program with multiple functions to perform arithmetic operations.


Program with multiple functions to convert temperature units.

Program with multiple functions to perform basic calculator operations.

Program with functions to find the minimum and maximum in an array.

Program with functions to calculate the average and standard deviation of an array

.Recursive Functions:

Program with a recursive function to calculate the Fibonacci series.


Program with a recursive function to find the factorial of a number.

Program with a recursive function to calculate the power of a number.

Program with a recursive function to reverse a string.

Program with a recursive function to calculate the GCD of two numbers.

Functions with Arrays

. Program with a function to find the sum of elements in an array.


Program with a function to find the largest element in an array.

Program with a function to sort elements in an array

.Program with a function to check if an array is a palindrome.

Program with a function to reverse the elements of an array

.Functions with File Handling:

Program with functions to read and display content from a file.


Program with functions to write data to a file.
Program with functions to count lines and words in a file.

Program with functions to find and replace text in a file.

Program with functions to copy content from one file to another

.User-Defined Data Types in Functions:

Program with a function to calculate the area of a circle using a custom class.
Program with a function to find the volume of a cylinder using a custom class
Function in java:

.Program with functions to perform operations on complex numbers.

Program with a function to manipulate a custom data structure

.Program with functions to validate and process user input

.Functions with Exception Handling:

. Program with a function that throws a custom exception.


Program with functions to handle different types of exceptions

.Program with a function to demonstrate try-catch-finally blocks.

Program with functions to read and handle input errors

.Program with a function to divide two numbers with exception handling.

Functions with Inheritance and Polymorphism:

. Program with functions in a base class and derived class.


Program with functions to demonstrate method overriding.

Program with functions to implement method overloading.

Program with functions to show interface implementation

.Program with functions using abstract classes and methods.

Functions with Database Operations:

Program with functions to connect to a database.

Program with functions to insert, update, and delete records in a database.

Program with functions to retrieve and display data from a database.

Program with functions to perform transactions in a database.

Program with functions to close a database connection.

You might also like