AHH C SUCKS
This commit is contained in:
parent
26c33a2b9c
commit
f6e26aa566
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -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
|
2
.idea/LearnC.iml
Normal file
2
.idea/LearnC.iml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/LearnC.iml" filepath="$PROJECT_DIR$/.idea/LearnC.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
CMakeLists.txt
Normal file
6
CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(LearnC C)
|
||||
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
|
||||
add_executable(LearnC main.c)
|
43
main.c
Normal file
43
main.c
Normal file
@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user