added ws202425 courses
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(){
|
||||
int i;
|
||||
int *ptr = &i;
|
||||
i = 1;
|
||||
printf("ptr = %p \n", ptr); // ptr = 0x7fffc953d9f4
|
||||
printf("*ptr = %d \n", *ptr); // *ptr = 1
|
||||
printf("i = %d \n", i);
|
||||
*ptr = 2;
|
||||
printf("i = %d \n", i);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int y;
|
||||
|
||||
int f(int param1, int param2){
|
||||
if (param2 == 0) {
|
||||
printf("Fehler: Division durch %d nicht möglich \n", param2);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else {
|
||||
int res = (2*(param1*param1)) / param2;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
int x = 4;
|
||||
while (1) {
|
||||
scanf("%d", &y); // scanf erwartet Speicheradresse
|
||||
if (y != 0){
|
||||
break;
|
||||
}
|
||||
else {
|
||||
printf("Fehler: Division durch 0 nicht möglich \n");
|
||||
}
|
||||
}
|
||||
printf("%d \n",f(x,y));
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void swap(int *a1, int *a2){
|
||||
int s = *a1;
|
||||
*a1 = *a2;
|
||||
*a2 = s;
|
||||
}
|
||||
-
|
||||
int main() {
|
||||
int var1 = 4;
|
||||
int var2 = 5;
|
||||
printf("var1: %d, var2: %d \n", var1, var2);
|
||||
swap(&var1, &var2);
|
||||
printf("swapped var1: %d, swapped var2: %d \n", var1, var2);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
int i;
|
||||
int *ptr = NULL;
|
||||
ptr = &i;
|
||||
i = 1;
|
||||
printf("Pointer Wert: \t\t\t %i\n", *ptr);
|
||||
printf("Pointer Adresse: \t\t %p\n", ptr);
|
||||
printf("Variablen Wert: \t\t %i\n", i);
|
||||
*ptr = 2;
|
||||
printf("Veraenderten Variablen Wert: \t %i\n", i);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int y;
|
||||
|
||||
int func(int a, int b){
|
||||
if (b == 0){
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return (2 * (a * a)) / b;
|
||||
}
|
||||
}
|
||||
|
||||
int main (void){
|
||||
int x = 4;
|
||||
printf("Geben Sie eine ganze Zahl ein: ");
|
||||
scanf("%i", &y);
|
||||
|
||||
int result = func(x,y);
|
||||
if(result == -1){
|
||||
printf("Ein Fehler ist aufgetreten.\n");
|
||||
} else {
|
||||
printf("Berechneter Wert: %i\n", result);
|
||||
}
|
||||
|
||||
for(int i = 0; i <= 30; i++){
|
||||
y = i;
|
||||
result = func(x,y);
|
||||
if(result == -1){
|
||||
printf("Ein Fehler ist aufgetreten.\n");
|
||||
} else {
|
||||
printf("x: %i, y: %i, z: %i\n", x,y, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void swap(int *a, int *b){
|
||||
int temp = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
int main(void){
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
printf("x: %i, y: %i\n",x,y);
|
||||
swap(&x, &y);
|
||||
printf("x: %i, y: %i\n",x,y);
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user