1#include <stdio.h>
2
3void function(){
4 printf("I am a function!");
5}
6
7int main(void) {
8
9 function();
10}
1#include <stdio.h>
2int addition(int num1, int num2)
3{
4 int sum;
5 /* Arguments are used here*/
6 sum = num1+num2;
7
8 /* Function return type is integer so we are returning
9 * an integer value, the sum of the passed numbers.
10 */
11 return sum;
12}
13
14int main()
15{
16 int var1, var2;
17 printf("Enter number 1: ");
18 scanf("%d",&var1);
19 printf("Enter number 2: ");
20 scanf("%d",&var2);
21
22 /* Calling the function here, the function return type
23 * is integer so we need an integer variable to hold the
24 * returned value of this function.
25 */
26 int res = addition(var1, var2);
27 printf ("Output: %d", res);
28
29 return 0;
30}
31
1#include <stdio.h>
2
3// Here is a function declaraction
4// It is declared as "int", meaning it returns an integer
5/*
6 Here are the return types you can use:
7 char,
8 double,
9 float,
10 int,
11 void(meaning there is no return type)
12*/
13int MyAge() {
14 return 25;
15}
16
17// MAIN FUNCTION
18int main(void) {
19 // CALLING THE FUNCTION WE MADE
20 MyAge();
21}
1#include <stdio.h>
2/* function return type is void and it doesn't have parameters*/
3void introduction()
4{
5 printf("Hi\n");
6 printf("My name is Chaitanya\n");
7 printf("How are you?");
8 /* There is no return statement inside this function, since its
9 * return type is void
10 */
11}
12
13int main()
14{
15 /*calling function*/
16 introduction();
17 return 0;
18}
19