Home | Hindi | Kabir | Poetry | Workshop | BoloKids | Writers | Contribute | Search | Contact                                                 Shop Online

  News
Channels
In Focus

Analysis  
Bolography  
Cartoons
Environment   
Opinion 

Columns
 Business
 My Word 
 PlainSpeak 
 Random Thoughts 
Our Heritage

Architecture
Astrology
Ayurveda
Buddhism
Cinema 
Culture
Dances
Festivals
Hinduism
History  
People  
Places 
Sikhism
Spirituality 
Vastu 
Vithika  

Society & Lifestyle

Family Matters 
Health
Parenting
Perspective 
Recipes
Society
Teens 
Women 

Creative Writings

Book Reviews
Ghalib's Corner
Humor
Individuality
Jagoji
Literary Shelf 
Love Letters  
Memoirs
Musings
Ramblings
Stories
Travelogues

Computing
  General Articles
 
CC++ 
  Flash 
  Internet Security 
 
Java 
 
Linux     
  Networking  

Computing | CC++   
User Defined Functions

We have mentioned earlier that one of the strengths of C language is that C functions are easy to define and use. C functions can be classified into two categories, namely, library functions and user-defined functions. main is an example of user defined function. printf and scanf belong to the category of library functions. The main distinction between user-defined and library function is that the former are not required to be written by user while the latter have to be developed by the user at the time of writing a program. However the user defined function can become a part of the C program library. 

The use of functions in C serves many advantages:

  1. It facilitates top-down modular programming . In this programming style, the high level of the overall problem is solved first while the details of each lower-level function are addressed later. 
      

  2. The length of a source program can be reduced by using functions at a appropriate places. 
      

  3. It is easy to locate and isolate a faulty function for further investigations. 
      

  4. A function may be used by many other programs. This means that a C programmer can build on what others have already done, instead of starting from scratch. 

A Multi-Function Program

A function in simple terms can be viewed as a black box which takes in some value (if required) and outputs some result. The internal details of the function are hidden from rest of the program. Every C program can be designed using a collection of these black boxes.


Consider an example as follows: 

displayname() 

printf("\nResult of displayname function call"); 

Above function can be used as follows 
main() 

printf("\nThis demonstrates user-defined functions"); 
displayname(); 

Output of this program is: 

This demonstrates user-defined functions 
Result of displayname function call 

First the printf statement in the main program is executed. This is followed by the call to the user-defined function displayname(), which results in execution of the statements within the body of the function. 

We will continue with the structure of functions and the methods of using function calls in the next article.    

– Sachin Mehta
May 11, 2001

C/C ++        
Managing Input-Output Operations
     
Managing Output Operations
    
Decision Making And Branching
     
Decision Making and Branching (if statement)
     
Decision Making and Looping
    
The Do Statement
   
Arrays
    
Arrays - Multi-Dimensional
    
Handling of Character Strings
    
Handling of Character Strings - 2  
User Defined Functions   
   User Defined Functions...contd    
Handling of Functions  

Computing
Flash | Internet Security 
Java | Linux | Networking  

General Articles  

Top | Previous | Next  
 


 

Recommend This Page!

Analysis | Architecture | Astrology | Ayurveda | Book Reviews | Buddhism | Cartoons | Cinema | Computing | Culture | Dances
Environment | Fables | Family Matters | Festivals | Hinduism | Health | History | Home Remedies | Humor | Individuality | Jagoji
Literary Shelf | Memoirs | Musings | Opinion | Parenting | Perspective | Photo Essays | Places | Ramblings
Random Thoughts | Recipes | Sikhism | Society | Spirituality | Stories | Teens | Travelogues | Vastu | Vithika | Women

Home | Hindi | Bolography | BoloKids | Kabir | Poetry | Quotes | Workshop | Writers | Contribute | Search | Contact


Boloji.com is owned and managed by Boloji Media Inc

Privacy Policy | Disclaimer
No part of this Internet site may be reproduced without prior written permission of the copyright holder.