User manual
ASURO - 63
-
C for ASURO
Now after some theory on data types and functions we would like to build a simple function,
multiplicating two 8-bit numbers and returning the result.
int Mult (char a, char b)
/* Function returns an int-value, is called Mult, and uses two char values for input */
{ // Begin function
int c; // Declaring variable c as an int
c = a * b; // calculate c
return c; // returning integer c
} // End of the function “Mult”
Now an example program, which will use the Mult-function we have de ned before:
int main (void) // Function main always returns an int and will not
// input any parameter
{ // Begin Function „main“
char mult1,mult2; // De ning two „char“-variables
int result; // De ning an int-variable for the result of multiplying
// variables mult1 und mult2
mult1 = 2; // assignment
mult2 = 10; // assignment
result = Mult(mult1,mult2); // calling the previously de ned function “Mult”
return 0;
} // End of function „main“