Valhalla Legends Forums Archive | C/C++ Programming | Compile Error!

AuthorMessageTime
ViLeNT
Can someone please look at this code.

When I try to compile it I get a scrolling list of errors.

If someone could modify it and repost it.....or tell me what im doing wrong I would appreciate it!

[CODE]

#include <stdio.h>


void getInput(int *pNum1, int *pNum2);
void calc(int num1, int num2, int *pSum, int *pDivint, int *pRemdiv, double *pHal1, double *pHal2, double *pQuot, int *pModeqn);
void intOps(int num1, int num2, int *pSum, int *pDivint, int *pRemdiv);
void doubleOps(int num1, int num2, double *pHal1, double *pHal2, double *pQuot);
int algebra(int num1, int num2);               
void display(int num1, int num2, int sum, int divint, int remdiv, double hal1, double hal2, double quot, double modeqn);

int main(void)
{
printf("\nName: Jai Jensen");

int num1, num2, sum, divint, remdiv, modeqn;
double hal1, hal2, quot, modeqn;


getInput(&num1, &num2);
calc(int num1, int num2, &sum, &divint, &remdiv, &hal1, &hal2, &quot, &modeqn);
display(num1, num2, sum, divint, remdiv, hal1, hal2, quot, modeqn);

return 0;
}

// Prompts User for Input
void getInput(int* pNum1, int* pNum2
{
printf("\Please enter two numbers: ");
scanf("%d %d", pNum1, pNum2);
}

// Funtions for operations
viod calc(int num1, int num2, int *pSum, int *pDivint, int *pRemdiv, double *pHal1, double *pHal2, double *pQuot, int *pModeqn);
{
intOps(num1, num2, pSum, pDivint, pRemdiv);
doubleOps(num1, num2, pHal1, pHal2, pQuot);
*pModeqn = algebra(num1, num2)
}

// Furntions for integer opterations
void calcintOps(int num1, int num2, int *pSum, int *pDivint, int *pRemdiv);
{
*pSum = num1 * num2;
        *pDivint = num1/num2;
        *pRemdiv = num1 % num2;
}

// Functions for double operations
void calcdoubleOps(int num1, int num2, double *pHal1, double *pHal2, double *pQuot);
{
*pHal1 = .5 * num1;
        *pHal2 = .5 * num2;
        *pQuot = (1.0 * num1)/ (num2);
}

// Function for answering equation
int algebra(int num1, int num2);
{
int pModeqn;
pModeq = (2 * num1) + (4 * num2) + (num1 * num2) - (num1/num2);
return pModeqn;
}

//Display
void display(int num1, int num2, int sum, int divint, int remdiv, float hal1, float hal2, float quot, float modeqn);
 
  printf("\n%20s%20s", "Description", "Data");
  printf("\n%20s%20s", "-----------", "----");
  printf("\n%20s%20d", "Input 1", num1);
  printf("\n%20s%20d", "Input 2", num2);
  printf("\n%20s%20d", "Sum", sum);
  printf("\n%20s%20.1f", "1/2 Input 1", hal1);
  printf("\n%20s%20.1f", "1/2 Input 2", hal2);
  printf("\n%20s%20d", "Division", divint);
  printf("\n%20s%20d", "Remainder", remdiv);
  printf("\n%20s%20.4f", "Quotient", quot);
  printf("\n%20s%20.3f", "2x + 4y + xy + x/y", modeqn);
  printf("\n\n");

  return 0;
}


[/CODE]
October 11, 2007, 2:31 AM
l2k-Shadow
umm.. look at what the compiler tells you the error is and fix it accordingly.
October 11, 2007, 2:36 AM
ViLeNT
do you recommend any specific compiler? or can you be more specific and tell me what im doing wrong?

im currently using a shitty generic compiler the school provided.
October 11, 2007, 2:39 AM
l2k-Shadow
Well VS 2005 would be the way to go imo.

But I just put it into my Visual Studio 6 and got the following:
[code]
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(17) : error C2371: 'modeqn' : redefinition; different basic types
        C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(16) : see declaration of 'modeqn'
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(21) : error C2144: syntax error : missing ')' before type 'int'
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(21) : error C2660: 'calc' : function does not take 0 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(21) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(29) : error C2143: syntax error : missing ')' before '{'
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(30) : warning C4129: 'P' : unrecognized character escape sequence
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(35) : error C2146: syntax error : missing ';' before identifier 'calc'
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(35) : error C2501: 'viod' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(35) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
[/code]
October 11, 2007, 2:48 AM
rabbit
[quote author=ViLeNT link=topic=17096.msg173761#msg173761 date=1192070352]
do you recommend any specific compiler? or can you be more specific and tell me what im doing wrong?

im currently using a shitty generic compiler the school provided.
[/quote]Look at the function definitions again, and then look at what you're passing to the functions.
October 11, 2007, 11:59 AM
DDA-TriCk-E
Also, your calc function is missing the final semi-colon after *pModeqn = algebra(num1, num2).  That could be causing a few of your other problems.
October 14, 2007, 12:17 PM

Search