A function is a independent block of statements that accomplish a articular assignment of some kind. Every C affairs can be anticipation of as a accumulating of these functions. As they acclaimed earlier, application a function is something like hiring a being to do a specific job for you. In the above programs we have used main at the starting, this main() itself is a function.A simple program illustrating the use of function is given below:
/*Example showing use of a function*/
main( )
{
printf ( "\nI am in main" ) ;
america( ) ;
printf ( "\nI am finally back in main" ) ;
}
america( )
{
printf ( "\nI am in america" ) ;
india( ) ;
printf ( "\nI am back in america" ) ;
}
india( )
{
printf ( "\nI am in india" ) ;
pakistan( ) ;
}
pakistan( )
{
printf ( "\nI am in pakistan" ) ;
}
Output:
I am in main
I am in america
I am in india
I am in pakistan
I am back in america
I am finally back in main
/*Example showing use of a function*/
main( )
{
printf ( "\nI am in main" ) ;
america( ) ;
printf ( "\nI am finally back in main" ) ;
}
america( )
{
printf ( "\nI am in america" ) ;
india( ) ;
printf ( "\nI am back in america" ) ;
}
india( )
{
printf ( "\nI am in india" ) ;
pakistan( ) ;
}
pakistan( )
{
printf ( "\nI am in pakistan" ) ;
}
Output:
I am in main
I am in america
I am in india
I am in pakistan
I am back in america
I am finally back in main
Sunday
//
Labels:
C LANGUAGE
//
0
comments
//
0 comments to "FUNCTIONS IN C LANGUAGE"
Powered by Blogger.
Blog Archive
-
▼
2011
(50)
-
▼
July
(38)
- INTRODUCTION TO C
- DATA SETS IN C
- DATA TYPES
- VARIABLES
- SIMPLE C PROGRAM
- PROGRAM USING SCANF() AND PRINTF()
- C INSTRUCTIONS
- INTRODUCTION TO DECISION CONTROL STRUCTURES
- IF STATEMENT
- IF STATEMENT PROGRAM
- IF ELSE STATEMENT
- NESTED IF ELSE
- DETERMINING ROOTS OF AN EQUATION
- ELSE IF STATEMENT
- LOGICAL AND ARITHMETIC OPERATORS
- CONDITIONAL OPERATORS
- LOOPS
- THE WHILE LOOP
- The for bend specify things about a bend in a ind...
- EXAMPLE OF FOR LOOP
- NESTING OF LOOPS
- THE ODD LOOP
- THE DO-WHILE LOOP
- BREAK STATEMENT IN C
- THE CONTINUE STATEMENT IN C
- SWITCH STATEMENT IN C
- SIMPLE PROGRAM SHOWING SWITCH STATEMENT
- THE GOTO STATEMENT IN C LANGUAGE
- FUNCTIONS IN C LANGUAGE
- CALLING FUNCTIONS IN C LANGUAGE
- CALL BY REFERENCE IN C LANGUAGE
- POINTERS IN C LANGUAGE
- SIMPLE PROGRAM SHOWING POINTER IN C LANGUAGE
- PROGRAM FOR FUNCTION CALL BY REFERENCE IN C
- SWAPPING OF TWO NUMBERS IN C
- RECURSION IN C LANGUAGE
- FACTORIAL OF A NUMBER WITHOUT RECURSION IN C
- ARRAYS IN C LANGUAGE
-
▼
July
(38)

Post a Comment