Student Of Fortune

Example Programs Using Functions in C + + Language

Share on :
hear the words of int, float, void, include? Or never saw the sign / /, #, {,}. Well it is one of the many programs that will be built using c + + language. This time we will discuss about Functions in c + + language. Function or in some literature there is to term it, subprogram and procedure, is one of the programming techniques to improve the modularity program that will be created. The greater the level of modularity, then the tendency is that the program will be relatively better. Here are some examples of type Void function and type Float.
Examples square program, that type of Void
# include
# include
/ / start function
void area (float s)
{
float large;
area = s * s;
court <<"large:" <
}
/ / end function
void main ()
{
float side;
court <<"calculate the area of square" <
court <<"Enter the side:"; cin>> side;
wide (side); / / calling function

getch ();

}
Examples of square program with function type Float
     # include
     # include

     / / start function
     float large (float s)
     {
     float large;
     large = s * s;
     return large; / / return value to function
     }
     / / end function

     void main ()
     {
     float side;
     float L;
     court <<"calculate the area of square" <
     court <<"Enter the side:"; cin>> side;
     L = large (side); / / call function and L contain the value of the function

     court <<"Size:" <

     getch ();

     }
 What is important to be aware of the type of function, it is better at adjusting the value return value.

0 comments on Example Programs Using Functions in C + + Language :

Post a Comment and Don't Spam!

Dont Spam please

 
Recommended Post Slide Out For Blogger

Recent Comments

My Rank