Skip to content

Commit 4b72640

Browse files
committed
lab4 did a bit
2031 lab4 zhiz
1 parent 4d6e90e commit 4b72640

File tree

8 files changed

+291
-0
lines changed

8 files changed

+291
-0
lines changed

2031Lab4/.cproject

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
3+
<storageModule moduleId="org.eclipse.cdt.core.settings">
4+
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643">
5+
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643" moduleId="org.eclipse.cdt.core.settings" name="Debug">
6+
<externalSettings/>
7+
<extensions>
8+
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
9+
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
10+
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
11+
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12+
</extensions>
13+
</storageModule>
14+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
15+
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
16+
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643." name="/" resourcePath="">
17+
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.711677012" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
18+
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1851263468" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
19+
<builder buildPath="${workspace_loc:/2031Lab4}/Debug" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1331303241" managedBuildOn="true" name="CDT Internal Builder.Debug" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
20+
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.511707420" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
21+
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.311769754" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
22+
</tool>
23+
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.657443388" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
24+
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.672238395" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug">
25+
<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.970701465" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
26+
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.1159421943" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" valueType="enumerated"/>
27+
</tool>
28+
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.278679937" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
29+
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1009869215" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" valueType="enumerated"/>
30+
<option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.161494873" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" valueType="enumerated"/>
31+
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.558753326" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
32+
</tool>
33+
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.1758558410" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug">
34+
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1952241330" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
35+
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
36+
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
37+
</inputType>
38+
</tool>
39+
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.531471307" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/>
40+
</toolChain>
41+
</folderInfo>
42+
</configuration>
43+
</storageModule>
44+
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
45+
</cconfiguration>
46+
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.707296021">
47+
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.707296021" moduleId="org.eclipse.cdt.core.settings" name="Release">
48+
<externalSettings/>
49+
<extensions>
50+
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
51+
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
52+
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
53+
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
54+
</extensions>
55+
</storageModule>
56+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
57+
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.707296021" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
58+
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.707296021." name="/" resourcePath="">
59+
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.390930327" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
60+
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.294574443" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
61+
<builder buildPath="${workspace_loc:/2031Lab4}/Release" id="cdt.managedbuild.tool.gnu.builder.mingw.base.580060243" managedBuildOn="true" name="CDT Internal Builder.Release" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
62+
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.1861716901" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release">
63+
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1384450538" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
64+
</tool>
65+
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.725191415" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
66+
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1956331179" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
67+
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.898065366" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
68+
<option defaultValue="gnu.cpp.compiler.debugging.level.none" id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.37524389" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" valueType="enumerated"/>
69+
</tool>
70+
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.102803583" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
71+
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.1480258663" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/>
72+
<option defaultValue="gnu.c.debugging.level.none" id="gnu.c.compiler.mingw.exe.release.option.debugging.level.841602693" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" valueType="enumerated"/>
73+
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2130788970" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
74+
</tool>
75+
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.1928861870" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release">
76+
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1277609917" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
77+
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
78+
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
79+
</inputType>
80+
</tool>
81+
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.16101095" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release"/>
82+
</toolChain>
83+
</folderInfo>
84+
</configuration>
85+
</storageModule>
86+
</cconfiguration>
87+
</storageModule>
88+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
89+
<project id="2031Lab4.cdt.managedbuild.target.gnu.mingw.exe.1501049657" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/>
90+
</storageModule>
91+
<storageModule moduleId="scannerConfiguration">
92+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
93+
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.707296021;cdt.managedbuild.config.gnu.mingw.exe.release.707296021.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.102803583;cdt.managedbuild.tool.gnu.c.compiler.input.2130788970">
94+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
95+
</scannerConfigBuildInfo>
96+
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643;cdt.managedbuild.config.gnu.mingw.exe.debug.829012643.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.278679937;cdt.managedbuild.tool.gnu.c.compiler.input.558753326">
97+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
98+
</scannerConfigBuildInfo>
99+
</storageModule>
100+
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
101+
</cproject>

2031Lab4/.project

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>2031Lab4</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
<buildCommand>
15+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16+
<triggers>full,incremental,</triggers>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
</buildSpec>
21+
<natures>
22+
<nature>org.eclipse.cdt.core.cnature</nature>
23+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
24+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
25+
</natures>
26+
</projectDescription>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project>
3+
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.829012643" name="Debug">
4+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
7+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
8+
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1109218075302724766" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
9+
<language-scope id="org.eclipse.cdt.core.gcc"/>
10+
<language-scope id="org.eclipse.cdt.core.g++"/>
11+
</provider>
12+
</extension>
13+
</configuration>
14+
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.release.707296021" name="Release">
15+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
16+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
17+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
18+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
19+
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1109218075302724766" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
20+
<language-scope id="org.eclipse.cdt.core.gcc"/>
21+
<language-scope id="org.eclipse.cdt.core.g++"/>
22+
</provider>
23+
</extension>
24+
</configuration>
25+
</project>

2031Lab4/a.exe

40.7 KB
Binary file not shown.

2031Lab4/function.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/***************************************
2+
* EECS2031B – Lab4 *
3+
* Author: Manoharan, Krishaanth *
4+
5+
* eecs_username: krish100 *
6+
* York Student #: 216463150
7+
****************************************/
8+
#include <stdio.h>
9+
10+
#define MY_PRINT(x,y,z) printf("running average is %d / %d = %.3f\n", x,y,z)
11+
12+
// define global variables and a function
13+
int sum;
14+
int count = 1;
15+
16+
void r_avg(void)
17+
{
18+
double resu = sum/ (double)count;
19+
MY_PRINT(sum, count, resu);
20+
count++;
21+
}

2031Lab4/runningAveGlobal.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/***************************************
2+
* EECS2031B – Lab4 *
3+
* Author: Manoharan, Krishaanth *
4+
5+
* eecs_username: krish100 *
6+
* York Student #: 216463150
7+
****************************************/
8+
#include <stdio.h>
9+
void r_avg(void);
10+
11+
int main(int argc, char *argv[])
12+
{
13+
int input;
14+
15+
printf("Enter number (-1 to quit): ");
16+
scanf("%d", &input);
17+
18+
while(input != -1){
19+
int sum;
20+
sum += input;
21+
r_avg();
22+
23+
// read again
24+
printf("Enter number (-1 to quit): ");
25+
scanf("%d", &input);
26+
27+
}
28+
29+
return 0;
30+
}

2031Lab4/runningAveLocal.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/***************************************
2+
* EECS2031B – Lab4 *
3+
* Author: Manoharan, Krishaanth *
4+
5+
* eecs_username: krish100 *
6+
* York Student #: 216463150
7+
****************************************/
8+
#include <stdio.h>
9+
10+
#define MY_PRINT(x,y,z) printf("running average is %d / %d = %.3f\n", x,y,z)
11+
12+
13+
void r_avg(int, int);
14+
15+
16+
int main(int argc, char *argv[])
17+
{
18+
19+
int input; int count=0; int sum=0;
20+
//double resu;
21+
22+
printf("Enter number (-1 to quit): ");
23+
scanf("%d", &input);
24+
25+
while(input != -1)
26+
{
27+
sum += input;
28+
29+
// resu = r_avg(sum, count);
30+
// My_PRINT(sum, count, resu);
31+
count++;
32+
r_avg(sum, count);
33+
/* read again */
34+
printf("\nEnter number (-1 to quit): ");
35+
scanf("%d", &input);
36+
37+
}
38+
39+
return 0;
40+
}
41+
42+
void r_avg(int sum, int count)
43+
{
44+
45+
double resu = sum/ (double)count;
46+
MY_PRINT(sum, count, resu);
47+
}

2031Lab4/runningAveLocal2.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/***************************************
2+
* EECS2031B – Lab4 *
3+
* Author: Manoharan, Krishaanth *
4+
5+
* eecs_username: krish100 *
6+
* York Student #: 216463150
7+
****************************************/
8+
#include <stdio.h>
9+
10+
#define MY_PRINT(x,y,z) printf("running average is %d / %d = %.3f\n", x,y,z)
11+
12+
void r_avg(int);
13+
14+
int main(int argc, char *argv[])
15+
{
16+
17+
int input;
18+
printf("Enter number (-1 to quit): ");
19+
scanf("%d", &input);
20+
21+
while (input != -1){
22+
r_avg(input);
23+
24+
printf("\nEnter number (-1 to quit): ");
25+
scanf("%d", &input);
26+
}
27+
28+
return 0;
29+
}
30+
31+
void r_avg(int input)
32+
{
33+
static int count = 1;
34+
static int sum = 0;
35+
36+
sum+= input;
37+
double resu = sum/ (double)count;
38+
MY_PRINT(sum, count, resu);
39+
count++;
40+
41+
}

0 commit comments

Comments
 (0)