diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/LearnC.iml b/.idea/LearnC.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/LearnC.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b97c92f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f19aae1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.23) +project(LearnC C) + +set(CMAKE_C_STANDARD 23) + +add_executable(LearnC main.c) diff --git a/main.c b/main.c new file mode 100644 index 0000000..d4ef824 --- /dev/null +++ b/main.c @@ -0,0 +1,43 @@ +#include + +const int MINUTES_PER_HOUR = 60; // This value cannot be changed later + +void types() { + // Datatypes: + int number = 16; // Whole number + float decimal = 3.1415; // Decimal number up to 7 points + double longDecimal = 3.1415926535; // Decimal up to 15 points + char letter = 'S'; // Single letter + char word[] = "Super"; // Multiple letters + + // Printing different datatypes + printf("%d\n", number); // Use %d or %i to print ints + printf("%f\n", decimal); // Use %f to print floats + printf("%lf\n", longDecimal); // Use %lf to print doubles + printf("%c\n", letter); // Use %c to print chars + printf("%s\n", word); // Use %s to print strings +} + +void operators() { + // Math operators + int x = 0; + + x = 5; // Assigns value 5 to variable x + x += 5; // Adds 5 to the value of x. Same as x = x + 5 + x -= 5; // Subtracts 5 from the value of x. Same as x = x - 5 + x *= 2; // Multiplies the value of x by 2. Same as x = x * 2 + x /= 2; // Divides the value of x by 2. Same as x = x / 2 + x %= 2; // Returns the remainder of the value of x / 2; Same as x = x % 2 + x &= 2; // TODO figure out wtf this does + x |= 2; // TODO figure out wtf this does + x ^= 2; // TODO figure out wtf this does + x >>= 2; // TODO figure out wtf this does + x <<= 2; // TODO figure out wtf this does +} + +int main() { + types(); + + printf("Hello, World!\n"); + return 0; +}