Kalvi c++ and python assesment
Kalvi c++ and python assesment
Most programming languages come with a prewritten set of functions that are kept in
a library. You can also write your own functions to perform specialized tasks.
The term function is also used synonymously with operation and command. For example,
you execute the delete function to erase a word.
Functions
- Modularize a program.
- All variables defined inside functions are local variables. (known only in function definition)
- Parameters
Benefits of functions
- Software reusability
These are the functions which are already built in the libraries of the programming
languages. In this module we will discuss about built in functions in C++ and Python.
User defined functions are the functions which are used to perform a specific task or
we can say that an action according to the user. User can modify the function as he
or she wants.
So, these type of functions which made or changed by the user are known as User-
defined functions.
# For C++:
Now , user defined function means we have to make the function by our own by
following the rules of C++ in another words we can say that by using correct syntax.
So, let’s head over to that syntax.
1.Function declaration
The below picture states that how we can declare a user-defined function.
2.Function definition
The below picture states that how can we define a user defined function
3.Function call
The below picture states that how can we call a user defined function in our
programme.
For better understanding let’s understand four types of user
defined functions in C++
1. Function with no return type and no arguments
Now , user defined function means we have to make the function by our own by
following the rules of Python in another words we can say that by using correct
syntax.
The syntax is somewhat different from C++ programming language but the working
and use is same in all the programming language whether it is C++ or python.
In python there is no return type even not the data type it is not that return type is not
there you can write return type if you want for your understanding. Return type is
optional here.
In syntax we will learn how to define a user defined function and how can we call it.
1.
2.