Computer Science & C Programming


Sub-programs definition & call

  1. The abs program computes a value (:the absolute value of x) and can be improved by using a return. The value returned can then be used in any integer expression
int abs() {
   int x = -12;
   if (x<0) { x=-x; } else {}
   //printf("%i",x);
   return x;
}

int main() {
   printf("%i", abs() );
}

3 - 10