Skip to content

Commit 42a5625

Browse files
authored
Add files via upload
0 parents  commit 42a5625

37 files changed

+2874
-0
lines changed

lab1/Debug/Lab1.c.o

4.79 KB
Binary file not shown.

lab1/Debug/Lab1.c.o.d

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Debug/Lab1.c.o: Lab1.c

lab1/Debug/lab1

8.4 KB
Binary file not shown.

lab1/Lab1

8.27 KB
Binary file not shown.

lab1/Lab1.c

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Description: C program that reads 3 integer inputs from the user and outputs the sum of the inputs, the first input negated, the number after the second input, and the product of the second and third input.
2+
* Author: Nicholas Ishankov - 1005798521
3+
* Date: 01/10/2020
4+
*/
5+
#include <stdio.h>
6+
7+
int main(int argc, char **argv)
8+
{
9+
//declare variables to store user inputs 1,2 and 3
10+
int inputNum1;
11+
int inputNum2;
12+
int inputNum3;
13+
14+
printf("Enter First Number: "); //prompt user to input integers
15+
scanf("%d", &inputNum1); //read user input and save to integer
16+
printf("Enter Second Number: ");
17+
scanf("%d", &inputNum2);
18+
printf("Enter Third Number: ");
19+
scanf("%d", &inputNum3);
20+
21+
printf("Sum: %d\n", inputNum1 + inputNum2 + inputNum3); //output sum of inputs
22+
printf("First negated: %d\n", -1*inputNum1); //output first input negated
23+
printf("After Number 2: %d\n", inputNum2+1); //output number after second input
24+
printf("Product of Number 2 and Number 3: %d\n", inputNum2*inputNum3); //output product of second and third input
25+
26+
return 0;
27+
}

lab1/Lab1.c.1

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Description: C program that reads 3 integer inputs from the user and outputs the sum of the inputs, the first input negated, the number after the second input, and the product of the second and third input.
2+
* Author: Nicholas Ishankov - 1005798521
3+
* Date: 01/10/2020
4+
*/
5+
#include <stdio.h>
6+
7+
int main(int argc, char **argv)
8+
{
9+
//declare variables to store user inputs 1,2 and 3
10+
int inputNum1;
11+
int inputNum2;
12+
int inputNum3;
13+
14+
printf("Enter First Number: "); //prompt user to input integers
15+
scanf("%d", &inputNum1); //read user input and save to integer
16+
printf("Enter Second Number: ");
17+
scanf("%d", &inputNum2);
18+
printf("Enter Third Number: ");
19+
scanf("%d", &inputNum3);
20+
21+
printf("Sum: %d\n", inputNum1 + inputNum2 + inputNum3); //output sum of inputs
22+
printf("First negated: %d\n", -1*inputNum1); //output first input negated
23+
printf("After Number 2: %d\n", inputNum2+1); //output number after second input
24+
printf("Product of Number 2 and Number 3: %d\n", inputNum2*inputNum3); //output product of second and third input
25+
26+
return 0;
27+
}

lab1/lab1.mk

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
##
2+
## Auto Generated makefile by CodeLite IDE
3+
## any manual changes will be erased
4+
##
5+
## Debug
6+
ProjectName :=lab1
7+
ConfigurationName :=Debug
8+
WorkspacePath :=/home/user/Desktop/APS105/aps105
9+
ProjectPath :=/home/user/Desktop/APS105/aps105/lab1
10+
IntermediateDirectory :=./Debug
11+
OutDir := $(IntermediateDirectory)
12+
CurrentFileName :=
13+
CurrentFilePath :=
14+
CurrentFileFullPath :=
15+
User :=APS 105 Student
16+
Date :=16/01/20
17+
CodeLitePath :=/home/user/.codelite
18+
LinkerName :=/usr/bin/g++
19+
SharedObjectLinkerName :=/usr/bin/g++ -shared -fPIC
20+
ObjectSuffix :=.o
21+
DependSuffix :=.o.d
22+
PreprocessSuffix :=.i
23+
DebugSwitch :=-g
24+
IncludeSwitch :=-I
25+
LibrarySwitch :=-l
26+
OutputSwitch :=-o
27+
LibraryPathSwitch :=-L
28+
PreprocessorSwitch :=-D
29+
SourceSwitch :=-c
30+
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
31+
Preprocessors :=
32+
ObjectSwitch :=-o
33+
ArchiveOutputSwitch :=
34+
PreprocessOnlySwitch :=-E
35+
ObjectsFileList :="lab1.txt"
36+
PCHCompileFlags :=
37+
MakeDirCommand :=mkdir -p
38+
LinkOptions :=
39+
IncludePath := $(IncludeSwitch). $(IncludeSwitch).
40+
IncludePCH :=
41+
RcIncludePath :=
42+
Libs :=
43+
ArLibs :=
44+
LibPath := $(LibraryPathSwitch).
45+
46+
##
47+
## Common variables
48+
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
49+
##
50+
AR := /usr/bin/ar rcu
51+
CXX := /usr/bin/g++
52+
CC := /usr/bin/gcc
53+
CXXFLAGS := -g -O0 -Wall $(Preprocessors)
54+
CFLAGS := -g -O0 -Wall $(Preprocessors)
55+
ASFLAGS :=
56+
AS := /usr/bin/as
57+
58+
59+
##
60+
## User defined environment variables
61+
##
62+
CodeLiteDir:=/usr/share/codelite
63+
Objects0=$(IntermediateDirectory)/Lab1.c$(ObjectSuffix)
64+
65+
66+
67+
Objects=$(Objects0)
68+
69+
##
70+
## Main Build Targets
71+
##
72+
.PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs
73+
all: $(OutputFile)
74+
75+
$(OutputFile): $(IntermediateDirectory)/.d $(Objects)
76+
@$(MakeDirCommand) $(@D)
77+
@echo "" > $(IntermediateDirectory)/.d
78+
@echo $(Objects0) > $(ObjectsFileList)
79+
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
80+
81+
MakeIntermediateDirs:
82+
@test -d ./Debug || $(MakeDirCommand) ./Debug
83+
84+
85+
$(IntermediateDirectory)/.d:
86+
@test -d ./Debug || $(MakeDirCommand) ./Debug
87+
88+
PreBuild:
89+
90+
91+
##
92+
## Objects
93+
##
94+
$(IntermediateDirectory)/Lab1.c$(ObjectSuffix): Lab1.c $(IntermediateDirectory)/Lab1.c$(DependSuffix)
95+
$(CC) $(SourceSwitch) "/home/user/Desktop/APS105/aps105/lab1/Lab1.c" $(CFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/Lab1.c$(ObjectSuffix) $(IncludePath)
96+
$(IntermediateDirectory)/Lab1.c$(DependSuffix): Lab1.c
97+
@$(CC) $(CFLAGS) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/Lab1.c$(ObjectSuffix) -MF$(IntermediateDirectory)/Lab1.c$(DependSuffix) -MM Lab1.c
98+
99+
$(IntermediateDirectory)/Lab1.c$(PreprocessSuffix): Lab1.c
100+
$(CC) $(CFLAGS) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Lab1.c$(PreprocessSuffix) Lab1.c
101+
102+
103+
-include $(IntermediateDirectory)/*$(DependSuffix)
104+
##
105+
## Clean
106+
##
107+
clean:
108+
$(RM) -r ./Debug/
109+
110+

lab1/lab1.project

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CodeLite_Project Name="lab1" Version="10.0.0" InternalType="Console">
3+
<Description/>
4+
<Dependencies/>
5+
<Settings Type="Executable">
6+
<GlobalSettings>
7+
<Compiler Options="" C_Options="" Assembler="">
8+
<IncludePath Value="."/>
9+
</Compiler>
10+
<Linker Options="">
11+
<LibraryPath Value="."/>
12+
</Linker>
13+
<ResourceCompiler Options=""/>
14+
</GlobalSettings>
15+
<Configuration Name="Debug" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
16+
<Compiler Options="-g;-O0;-Wall" C_Options="-g;-O0;-Wall" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
17+
<IncludePath Value="."/>
18+
</Compiler>
19+
<Linker Options="" Required="yes"/>
20+
<ResourceCompiler Options="" Required="no"/>
21+
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
22+
<BuildSystem Name="Default"/>
23+
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
24+
<![CDATA[]]>
25+
</Environment>
26+
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
27+
<DebuggerSearchPaths/>
28+
<PostConnectCommands/>
29+
<StartupCommands/>
30+
</Debugger>
31+
<PreBuild/>
32+
<PostBuild/>
33+
<CustomBuild Enabled="no">
34+
<RebuildCommand/>
35+
<CleanCommand/>
36+
<BuildCommand/>
37+
<PreprocessFileCommand/>
38+
<SingleFileCommand/>
39+
<MakefileGenerationCommand/>
40+
<ThirdPartyToolName>None</ThirdPartyToolName>
41+
<WorkingDirectory/>
42+
</CustomBuild>
43+
<AdditionalRules>
44+
<CustomPostBuild/>
45+
<CustomPreBuild/>
46+
</AdditionalRules>
47+
<Completion EnableCpp11="no" EnableCpp14="no">
48+
<ClangCmpFlagsC/>
49+
<ClangCmpFlags/>
50+
<ClangPP/>
51+
<SearchPaths/>
52+
</Completion>
53+
</Configuration>
54+
<Configuration Name="Release" CompilerType="GCC" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
55+
<Compiler Options="-O2;-Wall" C_Options="-O2;-Wall" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="0">
56+
<IncludePath Value="."/>
57+
<Preprocessor Value="NDEBUG"/>
58+
</Compiler>
59+
<Linker Options="" Required="yes"/>
60+
<ResourceCompiler Options="" Required="no"/>
61+
<General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Release" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
62+
<BuildSystem Name="Default"/>
63+
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
64+
<![CDATA[]]>
65+
</Environment>
66+
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
67+
<DebuggerSearchPaths/>
68+
<PostConnectCommands/>
69+
<StartupCommands/>
70+
</Debugger>
71+
<PreBuild/>
72+
<PostBuild/>
73+
<CustomBuild Enabled="no">
74+
<RebuildCommand/>
75+
<CleanCommand/>
76+
<BuildCommand/>
77+
<PreprocessFileCommand/>
78+
<SingleFileCommand/>
79+
<MakefileGenerationCommand/>
80+
<ThirdPartyToolName>None</ThirdPartyToolName>
81+
<WorkingDirectory/>
82+
</CustomBuild>
83+
<AdditionalRules>
84+
<CustomPostBuild/>
85+
<CustomPreBuild/>
86+
</AdditionalRules>
87+
<Completion EnableCpp11="no" EnableCpp14="no">
88+
<ClangCmpFlagsC/>
89+
<ClangCmpFlags/>
90+
<ClangPP/>
91+
<SearchPaths/>
92+
</Completion>
93+
</Configuration>
94+
</Settings>
95+
<VirtualDirectory Name="src">
96+
<File Name="Lab1.c"/>
97+
</VirtualDirectory>
98+
<Dependencies Name="Debug"/>
99+
<Dependencies Name="Release"/>
100+
</CodeLite_Project>

lab1/lab1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./Debug/Lab1.c.o

lab2/Lab2Part1

8.39 KB
Binary file not shown.

lab2/Lab2Part1.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Description: C program that calculates a ski rental charge with a user input daily rate, and rental period,
2+
* with a free day for every 3 days renting.
3+
* Author: Nicholas Ishankov - 1005798521
4+
* Date: 17/01/2020
5+
* */
6+
#include <stdio.h>
7+
8+
int main(int argc, char **argv)
9+
{
10+
float dailyRate; //declare float variable for daily rate
11+
int rentalPeriod; //declare integer variable for rental period
12+
int freeDays; //declare integer variable for number of free days
13+
const float hst = 1.13; //declare constant float for %13 tax multiplier
14+
15+
printf("Enter the daily rate: "); //prompt user to input data
16+
scanf("%f", &dailyRate); //read and save user input
17+
printf("Enter the rental period (in days): \n");
18+
scanf("%d", &rentalPeriod);
19+
20+
freeDays = rentalPeriod/4; //compute number of free days by performing integer division with rental period/4
21+
printf("Your total free day(s) in this rental is: %d\n", freeDays); //display total number of free days
22+
printf("The total charge including taxes is: %.2f\n", dailyRate*(rentalPeriod-freeDays)*hst); //compute and display total charge with 2 decimal points
23+
24+
return 0;
25+
}

lab2/Lab2Part2

8.32 KB
Binary file not shown.

lab2/Lab2Part2.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* Description: C program that decrypts a user input integer in the form d(9-b)(9-c)a to abcd.
2+
* Author: Nicholas Ishankov - 1005798521
3+
* Date: 17/01/2020
4+
* */
5+
6+
#include <stdio.h>
7+
8+
int main(int argc, char **argv)
9+
{
10+
int encrypted; //declare an integer variable to store the encrypted code
11+
12+
printf("Enter an encrypted 4-digit combination: "); //prompt the user to enter their encrypted integer
13+
scanf("%d", &encrypted); //read and save user input integer
14+
15+
//integer input in form d(9-b)(9-c)a and we need it in abcd.
16+
int a = encrypted%10; //yields 1's digit
17+
int c = -1*((encrypted/10)%10 - 9); //yields 10's digit - 9, then negated
18+
int b = -1*((encrypted/100)%10 - 9); //yields 100's digit - 9, then negated
19+
int d = (encrypted/1000)%10; //yields 1000's digit
20+
21+
printf("The real combination is: %d%d%d%d\n", a,b,c,d); //output decrypted integer in form abcd
22+
23+
return 0;
24+
}

lab2/Lab2Part3

8.64 KB
Binary file not shown.

lab2/Lab2Part3.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Description: C program that calculates the monthly payment for a car with user input purchase price,
2+
* down payment, finance term, and interest rate.
3+
* Author: Nicholas Ishankov - 1005798521
4+
* Date: 17/01/2020
5+
* */
6+
7+
#include <stdio.h>
8+
#include <math.h>
9+
10+
int main(int argc, char **argv)
11+
{
12+
int P; //declare variables
13+
int D;
14+
int n;
15+
float r;
16+
double M;
17+
18+
printf("Enter the purchase price P: "); //prompt user to input data
19+
scanf("%d", &P); //read and save user input
20+
printf("Enter the amount of down payment D: ");
21+
scanf("%d", &D);
22+
printf("Enter the finance term (in months): ");
23+
scanf("%d", &n);
24+
printf("Enter the monthly interest rate (in percent): ");
25+
scanf("%f", &r);
26+
27+
r/=100; //r must a percentage so /100
28+
M = ((P-D)*r*(pow((1+r),n)))/(pow((1+r),n)-1); //formula for monthly payment
29+
30+
printf("The monthly payment is: %.2lf\n", M); //output monthly payment M
31+
return 0;
32+
}

lab3/Lab3

15.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)