FUNCTIONS

Wooohoo !! you made it to this section congratulations now you are quite familiar with the syntax's and logic building for programming. So, why not let's level up the things..

 

In this section we will learn about Functions

 

So what is a Function ? 

 

 A function is a group of statements that together perform a specific task. Every C program has at least one function, which is main () we were using this in almost all our programs isn't it? We will talk about all these things in this section.

 

Why we use Functions?

 

  • Functions increases re-usability
  • Functions helps us in divide and conquer 
  • They help us in debugging a program
  • Develop applications, yes you heard right you can create your apps using C will discuss later.
  • Helps in code optimization

 

 Functions are further classified into two categories: 

  1. Single level Functions
  2. Multi level Functions

 lets talk about them:

  • Single level Functions

main( ){
 
printf("welcome to c program");
 

Output:
welcome to c program


  • Multi level Functions

main( ){
 
printf("welcome to c program");
disp_msg(); /* Function called from another level*/
printf("for good learning:);
 

disp_msg( ){
printf(" all the best:);
}

Output:
 welcome to c program all the best for good learning



 

 

Comments