diff --git a/ChangeLog b/ChangeLog index 3077bc6..0999d06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-02-14 Mert Gör + + * c-basic/C.pdf: CSD Derneği C temel notu tekrar C-Basic klasörüne eklendi ancak hwpplayer1 dalı için eklendi. Örnekler özgün olarak yeniden yazılacak. + 2024-02-04 Mert Gör * c-basic/global-variable-scope.c (foo): global variable and local variable explained with two different a variable value diff --git a/c-basic/foo.c b/c-basic/foo.c deleted file mode 100644 index b37e140..0000000 --- a/c-basic/foo.c +++ /dev/null @@ -1,45 +0,0 @@ -/** - -foo.c - foo example - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int foo() -{ - printf("I am foo\n"); -} - -int main() -{ - foo(); -} - -/** - In the written book it is foo() and main() and it returns this warning - ~/Projects/hwpplayer1/c-course/c-basic $ gcc foo.c -foo.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int] - 3 | foo() - | ^~~ -foo.c:8:1: warning: return type defaults to ‘int’ [-Wimplicit-int] - 8 | main() - | ^~~~ - **/ diff --git a/c-basic/global-variable-scope.c b/c-basic/global-variable-scope.c deleted file mode 100644 index b7667a7..0000000 --- a/c-basic/global-variable-scope.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - -global-variable-scope.c - global variable and their scopes explained - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int a; - -void foo(){ - a = 10; -} - -int main(){ - a = 30; - printf("%d\n", a); /* a is 30*/ - foo(); - printf("%d\n", a); /* a is 10*/ - - return 0; -} diff --git a/c-basic/helloworld.c b/c-basic/helloworld.c deleted file mode 100644 index 284ed18..0000000 --- a/c-basic/helloworld.c +++ /dev/null @@ -1,29 +0,0 @@ -/** - -helloworld.c - hello world example - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main(){ - printf("Hello World\n"); - return 0; -} diff --git a/c-basic/initialization-variable.c b/c-basic/initialization-variable.c deleted file mode 100644 index a33bbc7..0000000 --- a/c-basic/initialization-variable.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - -initialization-variable.c - Swap Algorithm with initialized variables example - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main(){ - int a = 10; - int b = 20; - int temp; - temp = a; - a = b; - b = temp; - - printf("a value is: %d\n", a); - printf("a value is: %d\n", b); - - return 0; -} - diff --git a/c-basic/local-variable-global-variable-scope.c b/c-basic/local-variable-global-variable-scope.c deleted file mode 100644 index c197fb9..0000000 --- a/c-basic/local-variable-global-variable-scope.c +++ /dev/null @@ -1,40 +0,0 @@ -/** - -local-variable-global-variable-scope.c - local variable and global variable explained - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main() { - int a; - - a = 10; - - { - int a; - a = 20; - printf("%d\n", a); /* a value is 20*/ - } - - printf("%d\n",a); /* a value is 10 because it comes from the global variable a value*/ - - return 0; -} diff --git a/c-basic/local-variable-scope.c b/c-basic/local-variable-scope.c deleted file mode 100644 index f1260aa..0000000 --- a/c-basic/local-variable-scope.c +++ /dev/null @@ -1,41 +0,0 @@ -/** - -local-variable-scope.c - local variable and global variable explained - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main() { - int a; - - { - int b; - - b = 20; - a = 10; - printf("a = %d, b = %d\n", a, b); /* correct */ - } - - printf("a = %d\n", a); /* correct */ - printf("b = %d\n", b); /* wrong */ - - return 0; -} diff --git a/c-basic/on-return-void.c b/c-basic/on-return-void.c deleted file mode 100644 index 82fc303..0000000 --- a/c-basic/on-return-void.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - -on-return.void.c - if we pass void then it means function has no return value, and those functions are void functions - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -void foo() { - printf("foo\n"); -} - -int main() { - printf("I am main\n"); - - foo(); - - return 0; -} - - - diff --git a/c-basic/on-return.2.c b/c-basic/on-return.2.c deleted file mode 100644 index 0a78b2c..0000000 --- a/c-basic/on-return.2.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - -on-return.2.c - explaining return value : "without return same result exists" - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main() { - - printf("I am main\n"); - - return 0; /* without this we'll see the same result*/ -} diff --git a/c-basic/on-return.c b/c-basic/on-return.c deleted file mode 100644 index 6d908fc..0000000 --- a/c-basic/on-return.c +++ /dev/null @@ -1,41 +0,0 @@ -/** - -on-return.c - explaining return value - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int foo() { - printf("foo example\n"); - printf("we can access this code\n"); /*reachable code! */ - return 100; - - printf("unreachable code\n"); /*unreachable code! */ -} - -int main() { - int result; - - result = foo() * 2; - printf("%d\n", result); - - return 0; -} diff --git a/c-basic/print_variables.c b/c-basic/print_variables.c deleted file mode 100644 index 3ed968e..0000000 --- a/c-basic/print_variables.c +++ /dev/null @@ -1,37 +0,0 @@ -/** - -print_variables.c - print variables with different ways - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main(){ - int a = 10; - int b = 20; - - // int a = 10, b = 20; is another option - - printf("a = %d, b = %d\n", a, b); - printf("a = %d, b = %d\n", b, a); - printf("a and b printed together = %d%d\n", a, b); - - return 0; -} diff --git a/c-basic/scanf-a-b-c-double.c b/c-basic/scanf-a-b-c-double.c deleted file mode 100644 index 0c5e5bb..0000000 --- a/c-basic/scanf-a-b-c-double.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - -scanf-a-b-c-double.c - set a,b,c double variables, read a and b with scanf function and then pass addition of a and b to c variable and print c variable - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - - -#include - -int main(){ - - double a,b,c; - - printf("a variable :"); - scanf("%lf", &a); - printf("b variable :"); - scanf("%lf", &b); - c = a + b; - printf("a + b = %f\n", c); - - return 0; -} diff --git a/c-basic/scanf-example-two-variables.c b/c-basic/scanf-example-two-variables.c deleted file mode 100644 index 6d61e61..0000000 --- a/c-basic/scanf-example-two-variables.c +++ /dev/null @@ -1,36 +0,0 @@ -/** - -scanf-example-two-variables.c - scanf example with two variables - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - - -#include - -int main(){ - int a; - int b; - - printf("enter two variables/numbers: "); - scanf("%d%d", &a, &b); - printf("a = %d, b = %d\n", a, b); - - return 0; -} diff --git a/c-basic/scanf-example.c b/c-basic/scanf-example.c deleted file mode 100644 index 74cd8b7..0000000 --- a/c-basic/scanf-example.c +++ /dev/null @@ -1,35 +0,0 @@ -/** - -scanf-example.c - gettıng input source via scancf - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - - -#include - -int main(){ - int a; - - printf("Enter a number: "); - scanf("%d", &a); - printf("The number you typed is : %d\n", a); - - return 0; -} diff --git a/c-basic/scanf-float-double.c b/c-basic/scanf-float-double.c deleted file mode 100644 index c515f4a..0000000 --- a/c-basic/scanf-float-double.c +++ /dev/null @@ -1,41 +0,0 @@ -/** - -scanf-float.c - Scanf reads float as %f and double %lf - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - - -#include - -int main() { - - float f; - double d; - - printf("enter your float variable: "); - scanf("%f", &f); - - printf("enter your double variable: "); - scanf("%lf", &d); - - printf("f = %f, d = %f\n", f, d); - - return 0; -} diff --git a/c-basic/scanf-hex.c b/c-basic/scanf-hex.c deleted file mode 100644 index f5cee9a..0000000 --- a/c-basic/scanf-hex.c +++ /dev/null @@ -1,35 +0,0 @@ -/** - -scanf-hex.c - Scanf accepts the int variable as hex if we pass %x - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - - -#include - -int main(){ - int a; - int b; - printf("enter a number : "); - scanf("%x", &a); - printf("a = %d\n", a); - - return 0; -} diff --git a/c-basic/scope.c b/c-basic/scope.c deleted file mode 100644 index d337d30..0000000 --- a/c-basic/scope.c +++ /dev/null @@ -1,53 +0,0 @@ -/** - -scope.c - scope and variables explained - -Copyright (C) 2023-2024 Mert Gör and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -Feel free to send an email to mertgor@masscollabs.xyz for your questions - - **/ - -#include - -int main() { - int a; - { - int b; - b = 20; - a = 10; - printf("a : %d, b : %d\n", a, b); // correct way to get done the job/task - } - printf("a : %d\n", a); // correct way to get done the job/task for a variable - // printf("b : %d\n", b); // error ! - /** - ~/Projects/hwpplayer1/c-course/c-basic $ gcc scope.c -scope.c: In function ‘main’: -scope.c:35:22: error: ‘b’ undeclared (first use in this function) - 35 | printf("b : %d\n", b); // error ! - | ^ -scope.c:35:22: note: each undeclared identifier is reported only once for each function it appears in - **/ - - return 0; - -} - -/** - ~/Projects/hwpplayer1/c-course/c-basic $ ./a.out -a : 10, b : 20 -a : 10 - **/