In any programming language the ability of the language to reuse a peice of code is vital and in C programming function provide us to way to do repetetive task easily, now i write a simple function that weil demonstrate the use of functions
#include<stdio.h>
int main()
{
hello(); //calling a function
}
void hello() //defining a function header
{
printf("hello world"); //function body
}
In above program we have written a very small function which allow us to print words hello world on the screen , the word void before the function name indicates the return value of function which in this case is none , every function returns a result which can be either integer, char, float or double or none is good practice to prefix function name with its return type
#include<stdio.h>
int main()
{
hello(); //calling a function
}
void hello() //defining a function header
{
printf("hello world"); //function body
}
In above program we have written a very small function which allow us to print words hello world on the screen , the word void before the function name indicates the return value of function which in this case is none , every function returns a result which can be either integer, char, float or double or none is good practice to prefix function name with its return type
0 comments:
Post a Comment