Skip to content
Justice Tech School

Functions

Declare return type, name and parameters. Call by name. void means no value.

Example
#include <stdio.h>

int square(int n) { return n * n; }
double half(double x) { return x / 2; }
void hello(void) { printf("hello\n"); }
int main(void) {
  printf("%d %.1f\n", square(5), half(9));
  hello();
  return 0;
}

Result

25 4.5
hello

Exercise

Return type for nothing.

 hello() {}

Quiz Test

What does void mean?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.