commit 37237f67f8e42a0c6b6c73005478f9aad800415c Author: kaltinsoy Date: Sun Nov 30 01:51:19 2025 +0300 initial diff --git a/a.out b/a.out new file mode 100755 index 0000000..28bc3c7 Binary files /dev/null and b/a.out differ diff --git a/charP.cpp b/charP.cpp new file mode 100644 index 0000000..3693a10 --- /dev/null +++ b/charP.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int countX (const char *p, const char *x) { + if (p==nullptr) { + return 0; + } + + int count = 0; + + for (; *p != 0; p++) { + if (*p == *x) { + count++; + } + } + return count; +} + +int main (void) { + cout << countX("Haaay, Koray", "a") << endl; + + return 0; +} diff --git a/classTest.cpp b/classTest.cpp new file mode 100644 index 0000000..34226d5 --- /dev/null +++ b/classTest.cpp @@ -0,0 +1,31 @@ +#include + +class Max { + private: + int mInt1, mInt2; + + public: + int int1, int2; + Max(int int1, int int2) : + mInt1 {int1}, mInt2 {int2} + { + } + + int bigger() { + if (int2 >= int1) { + return int2; + } else { + return int1; + } + } +}; + +int main(void) { + int x = 5, y = 7; + + Max max{x, y}; + + std::cout << max.bigger() << std::endl; + + return 0; +} diff --git a/funcT.cpp b/funcT.cpp new file mode 100644 index 0000000..9ec5aad --- /dev/null +++ b/funcT.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int fun1 (int); +int fun2 (int); + +int main (void) { + cout << fun1(4) + fun2(3) << endl; + + return 0; +} + +int fun1 (int i) { + return i; +} + +int fun2 (int j) { + return j; +} diff --git a/hello.cpp b/hello.cpp new file mode 100644 index 0000000..bb90336 --- /dev/null +++ b/hello.cpp @@ -0,0 +1,9 @@ +#include +using namespace std; + +int main (void) { + + cout << "Hello world!" << endl; + return 0; + +} diff --git a/importT.cpp b/importT.cpp new file mode 100644 index 0000000..a8007d2 --- /dev/null +++ b/importT.cpp @@ -0,0 +1,8 @@ +import std; + + +int main (void) { + std::cout << "Hello World!"; + + return 0; +} diff --git a/limits.cpp b/limits.cpp new file mode 100644 index 0000000..51428b0 --- /dev/null +++ b/limits.cpp @@ -0,0 +1,13 @@ +#include +#include + +using namespace std; + +int main (void) { + + cout << INT_MAX << endl; + cout << INT_MIN << endl; + + return 0; + +} diff --git a/stringConcatenation.cpp b/stringConcatenation.cpp new file mode 100644 index 0000000..13c7b27 --- /dev/null +++ b/stringConcatenation.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; +// return a string that contains n As +// In Java this code takes forever +string makeLongString( int n ) +{ +string result = ""; +for( int i = 0; i < n; i++ ) +result += "A"; +return result; +} +int main( ) +{ +string manyAs = makeLongString( 250000 ); +cout << "Short string is " << makeLongString( 20 ) << endl; +cout << "Length is " << manyAs.length( ) << endl; +return 0; +} diff --git a/sumV.cpp b/sumV.cpp new file mode 100644 index 0000000..4c1e2a0 --- /dev/null +++ b/sumV.cpp @@ -0,0 +1,21 @@ +#include +#include + +using namespace std; + +int vectorSum(const vector& v) { + int result = 0; + for(const int i : v) { + result += i; + } + return result; +} + +int main (void) { + + vector nums {2, 4, 6, 8, 10}; + cout << vectorSum(nums) << endl; + + return 0; + +} diff --git a/swap2.cpp b/swap2.cpp new file mode 100644 index 0000000..e6160bb --- /dev/null +++ b/swap2.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +void swap2 (int &val1, int &val2) { + int temp = val1; + val1 = val2; + val2 = temp; + } + +int main (void) { + int x = 1; + int y = 3; + + swap2(x, y); + + cout << x << y << endl; + + return 0; +} diff --git a/testParenth.cpp b/testParenth.cpp new file mode 100644 index 0000000..5bc15f7 --- /dev/null +++ b/testParenth.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; + +int main (void) { + int num {6}; + cout << num << endl; + return 0; +} diff --git a/vectorTest.cpp b/vectorTest.cpp new file mode 100644 index 0000000..ddde2b8 --- /dev/null +++ b/vectorTest.cpp @@ -0,0 +1,18 @@ +#include +#include + +using namespace std; + +int main (void) { + vector squares; + + for (int i = 0; i < 100; i++) { + squares.push_back(i * i); + } + + for (int j = 0; j < squares.size(); j++) { + cout << j << "squared is: " << squares[j] << endl; + } + + return 0; +}