Hi I wrote this C program but I keep getting these four errors: Severity Code De
ID: 3759365 • Letter: H
Question
Hi I wrote this C program but I keep getting these four errors:
Severity Code Description Project File Line
Error LNK1120 3 unresolved externals Stats Lab C:UsersMokodocumentsisual studio 2015ProjectsStats LabDebugStats Lab.exe 1
Warning C4129 '%': unrecognized character escape sequence Stats Lab c:usersmokodocumentsisual studio 2015projectsstats labstats labstats.c 69
Error LNK2019 unresolved external symbol _printTestScores referenced in function _main Stats Lab C:UsersMokodocumentsisual studio 2015ProjectsStats LabStats Labstats.obj 1
Error LNK2019 unresolved external symbol _printTestScoresInAscendingOrder referenced in function _main Stats Lab C:UsersMokodocumentsisual studio 2015ProjectsStats LabStats Labstats.obj 1
Error LNK2019 unresolved external symbol _printTestScoresAndFrequency referenced in function _main Stats Lab C:UsersMokodocumentsisual studio 2015ProjectsStats LabStats Labstats.obj 1
CODE:
#include <stdio.h>
#include <stdlib.h>
// Stats Lab
void sort(int testScores[], int numberOfScores);
void printTestScores(int testScores[], int numberOfScores);
void printTestScoresInAscendingOrder(int testScores[], int numberOfScores);
void printTestScoresAndFrequency(int testScores[], int numberOfScores);
void printPercentagePassingFailingGrades(int testScores[], int numberOfScores);
void printMeanModeMedianTestScores(int testScores[], int numberOfScores);
double greatestFrequencyScore = 0;
int main(void) {
int numberOfScores = 30;
int testScores[] = { 90, 85, 100, 50, 50, 85, 60, 70, 55, 55, 80, 95, 70, 60, 95, 80, 100, 75, 70, 95, 90, 90, 70, 95, 50, 65, 85, 95, 100, 65 };
printTestScores(testScores, numberOfScores);
printTestScoresInAscendingOrder(testScores, numberOfScores);
printTestScoresAndFrequency(testScores, numberOfScores);
printPercentagePassingFailingGrades(testScores, numberOfScores);
printMeanModeMedianTestScores(testScores, numberOfScores);
getchar(); getchar();
printf(" Value Frequency ");
int i, j;
i = 0;
j = 0;
int frequency[30];
double scores[30];
int index = 0;
for (i = 0; i <= numberOfScores - 1; i++)
{
frequency[i] = 0;
scores[j] = 0;
}
for (i = 0; i <= numberOfScores - 1; i++)
{
for (j = 0; j < index; j++) {
if (testScores[i] == scores[j]) {
frequency[j] = frequency[j] + 1;
break;
}
}
if (j == index) {
frequency[index] = frequency[j] + 1;
scores[index] = testScores[i];
index++;
}
}
greatestFrequencyScore = 0;
int freq = 0;
for (j = 0; j < index; j++) {
printf("%8.2f %d ", scores[j], frequency[j]);
if (frequency[j] > freq) {
freq = frequency[j];
greatestFrequencyScore = scores[j];
}
}
printf(" ");
}
void printPercentagePassingFailingGrades(int testScores[], int numberOfScores)
{
double passingTestScores = 0;
double failingTestScores = 0;
int i;
for (i = 0; i <= numberOfScores - 1; i++) {
if (testScores[i] >= 60)
passingTestScores++;
else if (testScores[i] < 60)
failingTestScores++;
}
printf("Percentage of passing scores = %.2f ", (passingTestScores * 100 / numberOfScores));
printf("Percentage of failing scores = %.2f ", (failingTestScores * 100 / numberOfScores));
printf(" ");
}
void printMeanModeMedianTestScores(int testScores[], int numberOfScores) {
int i;
double sumOfScores = 0;
for (i = 0; i <= numberOfScores - 1; i++) {
sumOfScores = sumOfScores + testScores[i];
}
double averageOfTwoMiddleNumbers = 0;
if (numberOfScores % 2 == 0)
averageOfTwoMiddleNumbers = (double)(testScores[numberOfScores / 2] + testScores[numberOfScores / 2 + 1]) / 2.0;
printf("Mean of test scores = %.2f ", sumOfScores / numberOfScores);
printf("Mode of test scores = %.2f ", greatestFrequencyScore);
printf("Median of test scores = %.2f ", averageOfTwoMiddleNumbers);
printf(" ");
}
If anyone could help me fix these errors that would be awesome
Explanation / Answer
#include <stdio.h>
#include <stdlib.h>
// Stats Lab
void sort(int testScores[], int numberOfScores);
void printTestScores(int testScores[], int numberOfScores);
void printTestScoresInAscendingOrder(int testScores[], int numberOfScores);
void printTestScoresAndFrequency(int testScores[], int numberOfScores);
void printPercentagePassingFailingGrades(int testScores[], int numberOfScores);
void printMeanModeMedianTestScores(int testScores[], int numberOfScores);
double greatestFrequencyScore = 0;
int main(void) {
int numberOfScores = 30;
int testScores[] = { 90, 85, 100, 50, 50, 85, 60, 70, 55, 55, 80, 95, 70, 60, 95, 80, 100, 75, 70, 95, 90, 90, 70, 95, 50, 65, 85, 95, 100, 65 };
//Please implement these functions as these functions are not implemented you are getting above errors
//printTestScores(testScores, numberOfScores);
//printTestScoresInAscendingOrder(testScores, numberOfScores);
//printTestScoresAndFrequency(testScores, numberOfScores);
printPercentagePassingFailingGrades(testScores, numberOfScores);
printMeanModeMedianTestScores(testScores, numberOfScores);
getchar(); getchar();
printf(" Value Frequency ");
int i, j;
i = 0;
j = 0;
int frequency[30];
double scores[30];
int index = 0;
for (i = 0; i <= numberOfScores - 1; i++)
{
frequency[i] = 0;
scores[j] = 0;
}
for (i = 0; i <= numberOfScores - 1; i++)
{
for (j = 0; j < index; j++) {
if (testScores[i] == scores[j]) {
frequency[j] = frequency[j] + 1;
break;
}
}
if (j == index) {
frequency[index] = frequency[j] + 1;
scores[index] = testScores[i];
index++;
}
}
greatestFrequencyScore = 0;
int freq = 0;
for (j = 0; j < index; j++) {
printf("%8.2f %d ", scores[j], frequency[j]);
if (frequency[j] > freq) {
freq = frequency[j];
greatestFrequencyScore = scores[j];
}
}
printf(" ");
}
void printPercentagePassingFailingGrades(int testScores[], int numberOfScores)
{
double passingTestScores = 0;
double failingTestScores = 0;
int i;
for (i = 0; i <= numberOfScores - 1; i++) {
if (testScores[i] >= 60)
passingTestScores++;
else if (testScores[i] < 60)
failingTestScores++;
}
printf("Percentage of passing scores = %.2f ", (passingTestScores * 100 / numberOfScores));
printf("Percentage of failing scores = %.2f ", (failingTestScores * 100 / numberOfScores));
printf(" ");
}
void printMeanModeMedianTestScores(int testScores[], int numberOfScores) {
int i;
double sumOfScores = 0;
for (i = 0; i <= numberOfScores - 1; i++) {
sumOfScores = sumOfScores + testScores[i];
}
double averageOfTwoMiddleNumbers = 0;
if (numberOfScores % 2 == 0)
averageOfTwoMiddleNumbers = (double)(testScores[numberOfScores / 2] + testScores[numberOfScores / 2 + 1]) / 2.0;
printf("Mean of test scores = %.2f ", sumOfScores / numberOfScores);
printf("Mode of test scores = %.2f ", greatestFrequencyScore);
printf("Median of test scores = %.2f ", averageOfTwoMiddleNumbers);
printf(" ");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.