Functions and its working in C++ (Part 1)

 Hello everybody. I am here with my newest post which is  called functions and its working in c++. Lets get started.

Functions:-
           It is a collection of statements which performs well defined task. Function is a set of instruction. Function has name, return type and arguments.
It is defined in Two types:
1) Predefined :  printf, scanf etc.                
 2) Userdefined: Created by programmer.
How Functions can work ? Here is the functions basic syntax which is used in programming.
returntype Name (arguments );

returntype means any value can be return or not.
Name(arguments); means function name with its arguments.
You can define function as locally and globally. You can also find more details about functions in my previous post. link is https://newageinformers.blogspot.in/2016/10/hellofriends.html        In here we will learn its different methods.
1) Take Something, Return Something.
2) Take Something, Return Nothing.
3) Take Nothing, Return Nothing.
4) Take Nothing, Return Something.

 1) TAKE SOMETHING RETURN SOMETHING:



In above program, at declaration part, function name is sum and function type is int. So value will be return in integer type.

Without declaration part, computer can not understand what is happening in this program.

In sum function we declared two arguments which is also in integer type.

In function definition part, we assume two variables in argument section which is called formal variables.

In main function we assume two another variables (a & b)its called actual variable. It will accept the value of (x & y) sequently.

We assume another variable name is W to store the result of sum in definition part.

                      Program starts from definition part. If we want to sum two integer variables x and y then we have to accept values from main function [void main]. after accept the values it will process in definition part and then answer will return to the calling part [ sum =(a,b) ]. This answer in store the third variable  W.                    
           After complete this steps then compiler will go in next step which is print the value. So computer will print the value whatever we gain.
            This is called take something (from main function) and return something(to calling function). This is also called call by value because in definition part we assume the ordinary variable which accept only value from main function part.

So this is it guys!!! In next post we will understand call by refrence and call by address. 
Until then BYE BYE !!!!
You can follow us here for our different updates.

Facebook: CLICK HERE!!!!!!!!!!


Twitter: @NewAgeInformers

Instagram: @new_age_informers

Youtube: CLICK HERE!!!!

















































































        

Comments