C_CPP/01_ENV/main.c

54 lines
840 B
C
Raw Normal View History

2018-03-09 09:47:53 +01:00
#include <stdio.h>
2018-03-12 15:20:16 +01:00
#include "func1.h"
2018-03-09 09:47:53 +01:00
int global = 8150;
int sum(int,int);
2018-03-12 21:11:29 +01:00
int sum(int a, int b) {
2018-03-09 09:47:53 +01:00
int result = 451;
result = a + b;
return result;
}
2018-03-12 21:11:29 +01:00
int main(int argc, char **argv) {
2018-03-09 09:47:53 +01:00
int local=4711;
printf("Hello, world!\nglobal=%d local=%d\n", global, local);
2018-03-12 21:11:29 +01:00
printf("Funktion 2: %d\n" , func2(2));
2018-03-13 12:50:42 +01:00
printf("Funktion 3: %d\n", func3(2));
2018-03-12 21:11:29 +01:00
2018-03-12 22:36:48 +01:00
2018-03-12 21:11:29 +01:00
int tmp = 0;
for(int i = 0; i <= 5; ++i) {
tmp += func3(i);
}
2018-03-12 23:17:36 +01:00
2018-03-12 21:11:29 +01:00
printf("For: %d\n", tmp);
2018-03-12 23:17:36 +01:00
2018-03-12 22:29:27 +01:00
tmp = 0;
2018-03-12 21:11:29 +01:00
int j = 0;
while(j <= 5) {
2018-03-12 22:29:27 +01:00
tmp += func3(j);
2018-03-12 21:11:29 +01:00
++j;
}
2018-03-12 23:17:36 +01:00
2018-03-12 22:29:27 +01:00
printf("While: %d\n", tmp);
2018-03-13 12:50:42 +01:00
2018-03-12 22:29:27 +01:00
tmp = 0;
int zeroes = 0;
2018-03-13 12:50:42 +01:00
for(int i = 0; i <= 20; ++i) {
if(func3(i) == 0) zeroes++;
2018-03-12 22:29:27 +01:00
}
printf("Nullstellen: %d\n", zeroes);
2018-03-12 23:17:36 +01:00
recurse1(20);
2018-03-13 12:50:42 +01:00
printf("\n");
2018-03-12 23:17:36 +01:00
recurse2(20);
2018-03-13 12:50:42 +01:00
printf("\n");
2018-03-12 21:11:29 +01:00
2018-03-09 09:47:53 +01:00
local = sum(global, local);
return local;
}