diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9e41c87 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "gcc.exe build and debug active file", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "gcc.exe build active file" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2272338..2540da4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,4 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { @@ -24,6 +22,24 @@ ], "group": "build" }, + { + "type": "shell", + "label": "gcc.exe build active file", + "command": "C:\\MinGW\\bin\\gcc.exe", + "args": [ + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "C:\\MinGW\\bin" + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build" + }, { "type": "shell", "label": "gcc.exe build active file", diff --git a/Assignment 6/abc.c b/Assignment 6/abc.c index 06d5ba2..9d96b7f 100644 --- a/Assignment 6/abc.c +++ b/Assignment 6/abc.c @@ -1,13 +1,33 @@ /* * Student: S.K. Soekhlal * Number: 4860632 - * Assignment: 3.4 + * Assignment: 3.6 */ -#include -#include #include -int discriminant(){ - +double x1real,x2real,ximag; +extern int a,b,c; /*Variables stored in another file*/ + +static float discriminant(){ + return (pow(b,2)-(4*a*c)); /*Calculate Discriminant */ +} + +void abc(){ + float D = discriminant(); + if (D>0){ + x1real = ((-b+sqrt(D))/(2.0*a)); + x2real = ((-b-sqrt(D))/(2.0*a)); + ximag = 0; + } + else if(D<0){ + x1real = -b/(2.0*a); + x2real = x1real; + ximag = (sqrt(-D)/(2.0*a)); + } + else{ + x1real = -b/(2.0*a); + x2real = x1real; + ximag = 0; + } } \ No newline at end of file diff --git a/Assignment 7/main.c b/Assignment 7/main.c new file mode 100644 index 0000000..e17ef98 --- /dev/null +++ b/Assignment 7/main.c @@ -0,0 +1,33 @@ +/* + * Student: S.K. Soekhlal + * Number: 4860632 + * Assignment: 4.3 + */ + +#include +#include +#include + +int main(){ + int m,n,i,j,c; + double price[100] = {0}; + int matrix[100][100]; + scanf("%d",&n); + for(i = 0; i +#include + +int main(){ + int a,b; + a = 7 % 4; + printf("%d\n",a); + b = (a += 2) +5; + printf("%d %d\n",a,++b); + return 0; +} \ No newline at end of file