funçoes c code example
Example 1: definir função em c
int sum(int N1, int N2)
{
int res;
res = N1 + N2;
return(res)
}
Example 2: how to write function in c
#include <stdio.h>
// Here is a function declaraction
// It is declared as "int", meaning it returns an integer
/*
Here are the return types you can use:
char,
double,
float,
int,
void(meaning there is no return type)
*/
int MyAge() {
return 25;
}
// MAIN FUNCTION
int main(void) {
// CALLING THE FUNCTION WE MADE
MyAge();
}
Example 3: functions in c programming
#include <stdio.h>
/* function return type is void and it doesn't have parameters*/
void introduction()
{
printf("Hi\n");
printf("My name is Chaitanya\n");
printf("How are you?");
/* There is no return statement inside this function, since its
* return type is void
*/
}
int main()
{
/*calling function*/
introduction();
return 0;
}