In this C tutorial section let learn the Multiple function program.
In C programming programmer can use or write multiple function in single program to achive modularity,better code management and simplicity etc.
A Program in C language with functions is considered better designed than a program having without any functions because
1.Repetition of code is reduced inside the program.
2.The program becomes very easy to read.
3.There will be no more chances of error in the program.
4.Complexity of the program will be reduced.
5.New updation and making changes is very easy.
Your program's source code can contain more than one function and can be called and executed.
Multiple Function Program.
C program to demonstrate multiple function inside the main() function.
#include<stdio.h>
void happyDiwali()
{
printf("\n Happy Diwali!");
}
void friendShipDay()
{
printf("\n Happy friendship Day!");
}
void happyNewYear()
{
printf("\n Happy new Year!");
}
int main()
{
// calling function
happyNewYear();
happyDiwali();
friendShipDay();
return(0);
}
Output:
Happy new Year!
Happy Diwali!
Happy friendship Day!
Program Explanation:
in the program given above we have declared and defined 3 functions happyNewYear(),happyDiwali() and friendShipDay() respectively.
after that in the main() function we have called the declared and defined function happyNewYear();,happyDiwali();,friendShipDay() one by one respectively.
Upon successful execution and completion of the program the called function gives the
Happy new Year! Happy Diwali! Happy friendship Day! result.
Previous Topic:-->> Need for User Defined Function in C || Next topic:-->>Modular Programming.
Other Topics:
Variables and Identifiers Relational Operators if-else statements Switch case While Loop Infinite while Loops C FOR Loop Infinite for Loops Continue in Loops One Dimensional Array Two Dimensional Arrays Read and Display 2D Arrays Types of functions Passing Array To Functions Nesting of Function Array vs Structure Array of Structure Structures and Functions Structures Within Structures Use Of Pointers In C File Handling In C Loops FAQ Arrays FAQ count vowels in a file Function FAQ Conditional Statements Assignments For Loops Assignments Arrays Assignments Function Assignments Structure Assignments Pointers Assignments Files Assignments Storage classes Assignments Binary Files count words,lines in a file Copy files Update File Continue in Loops break in Loops Difference Between While and Do while difference while do..while & for malloc calloc Storage Classes Operators MCQ Conditional Statements MCQ Loops MCQ Arrays MCQ Function MCQ Structure MCQ Pointers MCQ Files MCQ Storage classes MCQ