Init Commit

Signed-off-by: BuildTools <unconfigured@null.spigotmc.org>
This commit is contained in:
BuildTools
2021-01-03 16:05:51 -05:00
commit fe5ce2a18e
5 changed files with 60 additions and 0 deletions

1
README.md Normal file
View File

@@ -0,0 +1 @@
Learning C

BIN
a.out Executable file

Binary file not shown.

12
hello_world.c Normal file
View File

@@ -0,0 +1,12 @@
/*
* Learning C with some easy code
* Hello World
*/
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Hello world!\n");
return EXIT_SUCCESS;
}

36
sum.c Normal file
View File

@@ -0,0 +1,36 @@
/*
* Learning C with some easy code
* Sum of Input
*/
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
int main() {
int size = 1;
int sum = 0;
int pos = 0;
int* arr = malloc(size * sizeof(int));
while(TRUE) {
printf("Enter a number: ");
scanf("%d", &(arr[pos]));
printf("Num: %d\n", arr[pos]);
if( arr[pos] == 0 ) {
break;
}
size++;
int* new_arr = realloc(arr, size * sizeof(int));
arr = new_arr;
pos++;
}
for (int i = 0; i < size; i++) {
sum += arr[i];
}
printf("You sum is: %d\n", sum);
return EXIT_SUCCESS;
}

11
template.c Normal file
View File

@@ -0,0 +1,11 @@
/*
* Learning C with some easy code
* Hello World
*/
#include <stdio.h>
int main() {
printf("Hello world!");
return 0;
}