Here's my files:
1.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int xPosMatterCalc(int sigmaMatter, int muMatter, float xRand)
{
int xPosMatter = 1/(sigmaMatter*2.506627216)*exp(-((xRand-muMatter)*(xRand-muMatter))/(2*(sigmaMatter*sigmaMatter)));
return xPosMatter;
}
2.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int xPosAntiMatterCalc(int sigmaAntimatter, int muAntimatter, float xRand)
{
float xPosAntimatter = 1/(sigmaAntimatter*2.506627216)*exp(-pow((xRand-muAntimatter), 2)/(2*(pow(sigmaAntimatter, 2))));
return xPosAntimatter;
}
3.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "hw2-paulomans-1.h"
#include "hw2-paulomans-2.h"
int main(void)
{
int sigmaMatter = 4.2;
int muMatter = 27.0;
int sigmaAntimatter = 6.0;
int muAntimatter = 17.0;
int xRand = 0.0;
int seed = time(NULL);
srand(seed);
xRand = rand() % 36;
xPosMatterCalc(sigmaMatter, muMatter, xRand);
xPosAntiMatterCalc(sigmaAntimatter, muAntimatter, xRand);
float xProbability = xPosMatter * xPosAntimatter;
int i;
float count = 0.0;
float p = 0.0;
float pTotal = 0.0;
for(i =0; i <= 4999; i=i+1)
{
p = 0.09498629735*exp(-((27-xRand)*(27-xRand))/25.28)*0.06649040814*exp(-((17-xRand)*(17-xRand))/72);
count++;
pTotal = pTotal + p;
}
float pFinal = pTotal/count;
printf("\nSigma Matter: %d\nSigma Anti-matter: %d\nMu Matter: %d\nMu Anti-matter: %d", sigmaMatter, sigmaAntimatter, muMatter, muAntimatter);
printf("\nTotal iterations: %d", count);
printf("\nFinal probability: %d\n", pFinal);
}
1.h
Code:
int xPosMatterCalc(int sigmaMatter, int muMatter, float xRand);
2.h
Code:
int xPosAntiMatterCalc(int sigmaAntimatter, int muAntimatter, float xRand);
makefile
Code:
hw2make: hw2-paulomans-1.c hw2-paulomans-2.c hw2-paulomans-3.c
gcc -o hw2-paulomans hw2-paulomans-1.c hw2-paulomans-2.c hw2-paulomans-3.c -I.
When I try to execute the makefile, it gives me this error:
Code:
3.c: In function ‘main’:
3.c:20:23: error: ‘xPosMatter’ undeclared (first use in this function)
3.c:20:23: note: each undeclared identifier is reported only once for each function it appears in
3.c:20:36: error: ‘xPosAntimatter’ undeclared (first use in this function)
Can someone help me out?