diff --git a/dynamicalallocationofmemory.cpp b/dynamicalallocationofmemory.cpp new file mode 100644 index 0000000..c4d6b7c --- /dev/null +++ b/dynamicalallocationofmemory.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main() +{ + int n; + cin >> n; + + + double* b = new double[n]; // Using this approach, we do not + // have to declare n as constant + + return 0; +} diff --git a/inputfromcommandline.cpp b/inputfromcommandline.cpp new file mode 100644 index 0000000..210f2eb --- /dev/null +++ b/inputfromcommandline.cpp @@ -0,0 +1,11 @@ +#include + +using namespace std; + +int main(int argc, char* argv[]) // Add this rubbish to main +{ + // argv[0] is the program name + // arg[1] is the first argument + // arg[2] is the second argument and so on + return 0; +} diff --git a/test.cpp b/test.cpp index 0c053b8..e60dc11 100644 --- a/test.cpp +++ b/test.cpp @@ -9,11 +9,17 @@ using namespace std; +int func(int, int); + int main() { - const int n = 5; - double b[n] = {}; - n = 2; - } + int a = 1, b = 2; + cout << func(a, b); + return 0; +} + +int func(int a, int b) +{ + return a + b; }