mirror of
https://github.com/RustyRaptor/CS271.git
synced 2026-12-03 15:45:18 -07:00
start lab2 and made bin directories
This commit is contained in:
1 parent
b070e772f1
commit
ca31a75fd9
8 files changed
+87
-2
No files matched your search
@@ -30,3 +30,9 @@
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
|
||||
# VS Code Config
|
||||
.vscode/
|
||||
|
||||
*bin/
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
lab1: lab1.c
|
||||
gcc -Wall -Werror lab1.c -o lab1
|
||||
gcc -Wall -Werror lab1.c -o ./bin/lab1
|
||||
program1: program1.c
|
||||
gcc -Wall -Werror program1.c -o program1 -lm
|
||||
gcc -Wall -Werror program1.c -o ./bin/program1 -lm
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
fileInputExample-1: fileInputExample-1.c
|
||||
gcc -Wall -Werror fileInputExample-1.c -o ./bin/fileInputExample
|
||||
program1: program1.c
|
||||
gcc -Wall -Werror program1.c -o ./bin/program1 -lm
|
||||
@@ -0,0 +1,43 @@
|
||||
ACCheerios G 110 2 2 180 1.5 10.5 10
|
||||
Cheerios G 110 6 2 290 2.0 17.0 1
|
||||
CocoaPuffs G 110 1 1 180 0.0 12.0 13
|
||||
CountChocula G 110 1 1 180 0.0 12.0 13
|
||||
GoldenGrahams G 110 1 1 280 0.0 15.0 9
|
||||
HoneyNutCheerios G 110 3 1 250 1.5 11.5 10
|
||||
Kix G 110 2 1 260 0.0 21.0 3
|
||||
LuckyCharms G 110 2 1 180 0.0 12.0 12
|
||||
MultiGrainCheerios G 100 2 1 220 2.0 15.0 6
|
||||
OatmealRaisinCrisp G 130 3 2 170 1.5 13.5 10
|
||||
RaisinNutBran G 100 3 2 140 2.5 10.5 8
|
||||
TotalCornFlakes G 110 2 1 200 0.0 21.0 3
|
||||
TotalRaisinBran G 140 3 1 190 4.0 15.0 14
|
||||
TotalWholeGrain G 100 3 1 200 3.0 16.0 3
|
||||
Trix G 110 1 1 140 0.0 13.0 12
|
||||
Cheaties G 100 3 1 200 3.0 17.0 3
|
||||
WheatiesHoneyGold G 110 2 1 200 1.0 16.0 8
|
||||
AllBran K 70 4 1 260 9.0 7.0 5
|
||||
AppleJacks K 110 2 0 125 1.0 11.0 14
|
||||
CornFlakes K 100 2 0 290 1.0 21.0 2
|
||||
CornPops K 110 1 0 90 1.0 13.0 12
|
||||
CracklinOatBran K 110 3 3 140 4.0 10.0 7
|
||||
Crispix K 110 2 0 220 1.0 21.0 3
|
||||
FrootLoops K 110 2 1 125 1.0 11.0 13
|
||||
FrostedFlakes K 110 1 0 200 1.0 14.0 11
|
||||
FrostedMiniWheats K 100 3 0 0 3.0 14.0 7
|
||||
FruitfulBran K 120 3 0 240 5.0 14.0 12
|
||||
JustRightCrunchyNuggets K 110 2 1 170 1.0 17.0 6
|
||||
MueslixCrispyBlend K 160 3 2 150 3.0 17.0 13
|
||||
NutNHoneyCrunch K 120 2 1 190 0.0 15.0 9
|
||||
NutriGrainAlmondRaisin K 140 3 2 220 3.0 21.0 7
|
||||
NutriGrainWheat K 90 3 0 170 3.0 18.0 2
|
||||
Product19 K 100 3 0 320 1.0 20.0 3
|
||||
RaisinBran K 120 3 1 210 5.0 14.0 12
|
||||
RiceKrispies K 110 2 0 290 0.0 22.0 3
|
||||
Smacks K 110 2 1 70 1.0 9.0 15
|
||||
SpecialK K 110 6 0 230 1.0 16.0 3
|
||||
CapNCrunch Q 120 1 2 220 0.0 12.0 12
|
||||
HoneyGrahamOhs Q 120 1 2 220 1.0 12.0 11
|
||||
Life Q 100 4 2 150 2.0 12.0 6
|
||||
PuffedRice Q 50 1 0 0 0.0 13.0 0
|
||||
PuffedWheat Q 50 2 0 0 1.0 10.0 0
|
||||
QuakerOatmeal Q 100 5 2 0 2.7 1.0 1
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
|
||||
FILE *filePtr;
|
||||
int age, count = 0, total = 0;
|
||||
char last[30], first[20];
|
||||
if (( filePtr = fopen("sampleData.txt", "r")) == NULL )
|
||||
|
||||
printf( "File could not be opened\n" );
|
||||
|
||||
else { // file open was successful
|
||||
|
||||
fscanf(filePtr, " %s%s%d", first, last, &age);
|
||||
|
||||
while ( !feof( filePtr ) ) {
|
||||
count++;
|
||||
total += age;
|
||||
|
||||
fscanf(filePtr, " %s%s%d", first, last, &age);
|
||||
} // end while
|
||||
|
||||
printf("Average age of the %d people in the study is %.1f.\n",
|
||||
count, (float)total / count);
|
||||
fclose( filePtr );
|
||||
} // end else
|
||||
|
||||
} // end main
|
||||
|
||||
Reference in new issue
Block a user