| functions/input-parameter-problems/p6.c - Brug af globale variable til input og output. | Lektion 5 - slide 26 : 30 Program 5 |
/* Communication via global variables - works - EVEN WORSE */
#include <stdio.h>
#include <math.h>
double katete1, katete2, result;
void hypotenuse (void){
result = sqrt(katete1 * katete1 + katete2 * katete2);
}
int main(void) {
printf("Indlaes to kateter: ");
scanf("%lf %lf", &katete1, &katete2);
hypotenuse();
printf("Katete1: %f, katete2: %f, hypotenuse: %f\n",
katete1, katete2, result);
}