This commit is contained in:
akoray420 2023-09-23 22:20:41 +03:00
parent 609aa52e66
commit 66997adad5
42 changed files with 642 additions and 0 deletions

BIN
a.exe Executable file

Binary file not shown.

21
arrayfunc.c Executable file
View File

@ -0,0 +1,21 @@
#include <stdio.h>
void myFunc(int myNum[5]) {
for (int i = 0; i < 5; i++) {
printf("%d\n", myNum[i]);
}
{
int i = 0;
while (i < 5) {
printf("%d\n", myNum[i]);
i++;
}
}
}
int main() {
int myNum[5] = {25, 50, 75, 100, 125};
myFunc(myNum);
return 0;
}

12
arrays.c Executable file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main() {
int myNumbers[] = {11, 22, 33, 44, 55};
printf("%d\n", myNumbers[4]);
int matrix[2][3] = { {1, 4, 9}, {2, 5, 7} };
printf ("%d\n", matrix[1][2]);
printf ("%p", &myNumbers);
return 0;
}

14
booleans.c Executable file
View File

@ -0,0 +1,14 @@
#include <stdbool.h>
#include <stdio.h>
int main() {
int votingAge = 18;
int myAge = 18;
if (myAge > votingAge) {
printf("Oy verebilirsiniz!");
} else if (myAge == votingAge) {
printf("test2");
} else {
printf("test1");
}
}

11
charfunc.c Executable file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
void myFunc(char name[], int age) {
printf("Hello %s. You're %d years old\n", name, age);
}
int main() {
myFunc("Liam", 3);
myFunc("Ahmet", 30);
return 0;
}

13
declarition.c Executable file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int myFunc(int,int);
int main(){
int result = myFunc(5, 3);
printf("Result is %d", result);
return 0;
}
int myFunc(int x, int y){
return x + y;
}

14
fgets.c Executable file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
int main() {
int test1;
char test2[50];
char test3[50];
printf("Test box! : ");
fgets(test2, sizeof(test2), stdin);
printf("WORKING! : %s", test2);
printf("TEST2! : ");
fgets(test3, sizeof(test3), stdin);
printf("WORKING2!: %s", test3);
return 0;
}

12
file.c Executable file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main() {
FILE *fptr;
fptr = fopen("test1.txt", "a");
fprintf(fptr, "\nThis is Working!");
fclose(fptr);
return 0;
}

16
fileopen.c Executable file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
int main () {
FILE *fptr;
fptr = fopen("test1.txt", "r");
char myStr[100];
while(fgets(myStr, 100, fptr)) {
printf("%s", myStr);
}
fclose (fptr);
return 0;
}

15
for loop.c Executable file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 2; ++i) {
printf("test: %d\n", i);
for (j = 1; j <= 3; ++j) {
printf("test2 : %d\n", j);
}
}
return 0;
}

11
function.c Executable file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
void myFunc() {
printf("My first Function!");
}
int main() {
myFunc();
return 0;
}

12
function2.c Executable file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int myProg(int x) {
return x + 3;
}
int main() {
int y = 5;
printf("%d\n", myProg(y));
return 0;
}

27
hello.c Executable file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
int main() {
// Learning C types
int myNum;
char myChar;
float myFloat;
myChar = 'a';
myFloat = 1.55;
int myNumero = 11;
myNum = myNumero;
int x = 4;
int y = 10;
int suma = x + y;
int a = 10, b = 20, c = 30;
float sum = (float) y / x;
int myInt = 9.99;
//printf("My fav number is :%d\n", myNum);
printf("%lu\n", sizeof(myFloat));
printf("%lu\n", sizeof(myChar));
//printf("My fav number is: %d\t and My fav character is: %c\n", myNum, myChar);
printf("%lu\n", sizeof(suma));
//printf("%d\n", a + b +c);
//printf("%.1f\n", sum);
printf("%lu\n", sizeof(myInt));
return 0;
}

14
input.c Executable file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
int main() {
int sakiriNum;
char sakireDeger[30];
printf("Please, enter a number: \n");
scanf("%d", &sakiriNum);
printf("Please, enter your name: \n");
scanf("%s", sakireDeger);
printf("You pressed sakir: %d,", sakiriNum);
printf(" %s!", sakireDeger);
return 0;
}

BIN
learnc/a.exe Executable file

Binary file not shown.

33
learnc/learnc1.c Executable file
View File

@ -0,0 +1,33 @@
#include <stdio.h>
int main() {
float average;
int grades[2][5];
int i;
int j;
grades[0][0] = 80;
grades[0][1] = 70;
grades[0][2] = 65;
grades[0][3] = 89;
grades[0][4] = 90;
grades[1][0] = 85;
grades[1][1] = 80;
grades[1][2] = 80;
grades[1][3] = 82;
grades[1][4] = 87;
/* TODO: complete the for loop with appropriate terminating conditions */
for (i = 0; i < 2; i++) {
average = 0;
for (j = 0; j < 5; j++) {
average += grades[i][j];
}
/* TODO: compute the average marks for subject i */
printf("The average marks obtained in subject %d is: %.2f\n", i, average);
}
return 0;
}

23
learnc/learnc10.c Executable file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
typedef struct {
char * name;
int age;
} person;
/* function declaration */
void birthday(person * p) {
p->age++;
}
int main() {
person john;
john.name = "John";
john.age = 27;
printf("%s is %d years old.\n", john.name, john.age);
birthday(&john);
printf("Happy birthday! %s is now %d years old.\n", john.name, john.age);
return 0;
}

19
learnc/learnc11.c Executable file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int x;
int y;
} point;
int main() {
point * mypoint;
mypoint = (point *)malloc(sizeof(point));
mypoint->x = 10;
mypoint->y =5 ;
printf("mypoint coordinates: %d, %d\n", mypoint->x, mypoint->y);
free(mypoint);
return 0;
}

17
learnc/learnc2.c Executable file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
void guessNumber(int guess) {
if (guess == 555) {
printf("Correct. You guessed it!\n");
} if (guess < 555) {
printf("Your guess is too low.\n");
} if (guess > 555) {
printf("Your guess is too high.\n");
}
}
int main() {
guessNumber(500);
guessNumber(600);
guessNumber(555);
}

18
learnc/learnc3.c Executable file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <string.h>
int main() {
char first_name[5] = "John";
char last_name[4] = "Boe";
char name[100];
last_name[0] = 'B';
sprintf(name, "%s %s", first_name, last_name);
if (strncmp(name, "John Boe", 100) == 0) {
printf("Done!\n");
}
name[0]='\0';
strncat(name,first_name,4);
strncat(name,last_name,20);
printf("%s\n",name);
return 0;
}

13
learnc/learnc4.c Executable file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main() {
int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int factorial = 1;
int i;
for (i = 0; i < 10; i++) {
factorial *= array[i];
}
printf("10! is %d.\n", factorial);
}

22
learnc/learnc5.c Executable file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int main() {
int array[] = {1, 7, 4, 5, 9, 3, 5, 11, 6, 3, 4};
int i = 0;
while (i < 10) {
if (array[i] < 5){
i++;
continue;
}
if (array[i] < 10) {
printf("%d\n", array[i]);
i++;
if (array[i] > 10){
break;
}
}
}
return 0;
}

17
learnc/learnc6.c Executable file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
void print_big(int number);
int main() {
int array[] = { 1, 11, 2, 22, 3, 33 };
int i;
for (i = 0; i < 6; i++) {
print_big(array[i]);
}
return 0;
}
void print_big(int number) {
if(number > 10) {
printf("%d is big\n",number);
}
}

13
learnc/learnc7.c Executable file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int sum (int num) {
static int total = 0;
total += num;
return total;
}
int main() {
printf("%d ",sum(55));
printf("%d ",sum(45));
printf("%d ",sum(50));
return 0;
}

15
learnc/learnc8.c Executable file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main() {
int n = 10;
int * pointer_to_n = &n;
n += 1;
/* testing code */
if (pointer_to_n != &n) return 1;
if (*pointer_to_n != 11) return 1;
printf("Done!\n");
return 0;
}

15
learnc/learnc9.c Executable file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
typedef struct {
char * name;
int age;
} person;
int main() {
person john;
/* testing code */
john.name = "John";
john.age = 27;
printf("%s is %d years old.", john.name, john.age);
}

11
loop.c Executable file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
int main() {
int i = 0;
while (i >= 5) {
printf("%d\n", i);
i++;
}
}

16
math.c Executable file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
#include <math.h>
int myProg(int, int);
int main(){
float fullNum;
int b;
printf("Lutfen rakam giriniz! \n");
scanf("%f\n", &fullNum);
printf("%f\n", ceil(fullNum));
printf("%f", floor(fullNum));
return 0;
}

13
matrix.c Executable file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
int main() {
int matrix[2][3] = { {1, 2, 3}, {4, 5, 6} };
int i,j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
printf ("%d\n", matrix[i][j]);
}
}
return 0;
}

14
pointer.c Executable file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
int main () {
int speedTrain = 150;
int* ptr = &speedTrain;
printf("%d\n", speedTrain);
printf("%p\n", &speedTrain);
printf("%p\n", ptr);
printf("%d\n", *ptr);
return 0;
}

16
pointerarrays.c Executable file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
int main() {
int myNum[4] = {25, 50, 75, 100};
int i;
int j;
for (i = 0; i < 4; i++) {
printf("%p\n", &myNum[i]);
}
printf("%lu\n", sizeof(j));
printf("%p\n", myNum);
printf("%p\n", &myNum[0]);
printf("%lu\n", sizeof(myNum));
return 0;
}

15
pointerarrays2.c Executable file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main() {
int myNumbers[4] = {25, 50, 75, 100};
int *ptr = myNumbers;
int i;
*myNumbers = 101;
*(myNumbers + 1) = 55;
for (i = 0; i < 4; i++) {
printf("%d\n", *(ptr + i));
}
printf("%d\n", *(myNumbers + 1));
return 0;
}

22
recursion.c Executable file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int myProg(int k);
int main() {
int b;
printf("Type a num: \n");
scanf("%d", &b);
int result = myProg(b);
printf("%d\n", result);
return 0;
}
int myProg(int k) {
if (k > 10) {
return k + myProg(k - 1);
} else {
return 0;
}
}

7
specialstrings.c Executable file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main () {
char txt[] = "If i live in a \"different\" universe i love you";
printf ("%s", txt);
return 0;
}

10
string.c Executable file
View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <string.h>
int main () {
char test[40] = "TESTING";
char test2[50] = " WORKING";
char test3[50] = "TESTING";
printf("%d", strcmp(test, test3));
return 0;
}

8
strings.c Executable file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
int main () {
char greetings[] = "Hello!";
greetings[0] = 'Y';
printf("%s\n", greetings);
return 0;
}

17
stringsloop.c Executable file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
int main () {
char carName[] = "GOLF";
int i;
int j = 0;
while (j < 5) {
for (i = 0; i < 5; i++) {
printf ("%c\t", carName[i]);
}
printf ("\n");
j++;
}
return 0;
}

28
structer.c Executable file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <string.h>
struct myStruct {
int myNum;
char myLtr;
char myString[30];
};
int main () {
struct myStruct s1;
s1.myNum = 10;
s1.myLtr = 'a';
strcpy(s1.myString, "Greetings!");
struct myStruct s2;
s2.myNum = 19;
s2.myLtr = 'C';
printf("%s\n", s1.myString);
printf("%d\n", s1.myNum);
printf("%c\n", s1.myLtr);
printf("%d\n", s2.myNum);
printf("%c\n", s2.myLtr);
return 0;
}

17
structer2.c Executable file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <string.h>
struct myStruct {
int myNum;
char myNam[30];
};
int main () {
struct myStruct s3 = {15, "Hello World!"};
printf("%d\n%s", s3.myNum, s3.myNam);
return 0;
}

42
switch.c Executable file
View File

@ -0,0 +1,42 @@
#include <stdio.h>
int main() {
int day = 8;
switch (day) {
case 1:
printf("monday");
break;
case 2:
printf("tuesday");
break;
case 3:
printf("wednesday");
break;
case 4:
printf("thursday");
break;
case 5:
printf("friday");
break;
case 6:
printf("saturday");
break;
case 7:
printf("sunday");
break;
default:
printf("there's 7 day in week!");
}
}

2
test1.txt Executable file
View File

@ -0,0 +1,2 @@
Hello World!
This is Working!

7
test2.c Executable file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main() {
int x = 7;
int y = 5;
printf ("%d\n", !(x > 4 && y > 4));
}