|
-
Jun 9th, 2002, 05:19 PM
#1
Thread Starter
Addicted Member
Kind a beginner thingie...
Hi
For about an hour now I'm trying to get with my head through the wall, but I can't.. ;o)
I really can't figure out what't the problem with my program. It's something with variables and &-operator, but what...
Can someone please look at it?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
void getFunctionParameters(void);
void sqeq(double a, double b, double c, double &x1r, double &x1i, double &x2r, double &x2i);
//void sqeq(double &a, double &b, double &c, double &x1r, double &x1i, double &x2r, double &x2i);
//void sqeq(double a, double b, double c, double x1r, double x1i, double x2r, double x2i);
double paramA, paramB, paramC;
int main(int argc, char* argv[]) {
double X1r = 0, X1i = 0, X2r = 0, X2i = 0;
if (argc == 1)
getFunctionParameters();
else {
printf("\n/--------------------------------------------------\\\n");
printf("| Program za izracun vrednosti kvadratne funkcije. |\n");
printf("| |\n");
printf("| (C) 2002 by Tanja Vasilevska |\n");
printf("\\--------------------------------------------------/\n");
exit(0);
}
sqeq(paramA, paramB,paramC, X1r, X1i, X2r, X2i);
printf("Rezultat:\n");
if (X1i == 0 && X2i == 0) {
printf("\tX1 = %f\n", X1r);
printf("\tX2 = %f\n", X2r);
}
else {
printf("\tRe(X1) = %f; Im(X1) = %f\n", X1r, X1i);
printf("\tRe(X2) = %f; Im(X2) = %f\n", X2r, X2i);
}
return 0;
}
void getFunctionParameters(){
char pravilen = ' ';
float A, B, C;
printf("----------------------------------------------\n");
printf("Vpiši vrednost parametra A: ");
scanf("%f", &A);
printf("Vpiši vrednost parametra B: ");
scanf("%f", &B);
printf("Vpiši vrednost parametra B: ");
scanf("%f", &C);
printf("----------------------------------------------\n");
printf("Funkcija: 0 = %fx^2 + %fx + %f\n", A, B, C);
printf("----------------------------------------------\n");
paramA = (double)A;
paramB = (double)B;
paramC = (double)C;
}
void sqeq(double a, double b, double c, double &x1r, double &x1i, double &x2r, double &x2i) {
double d = b * b - 4 * a * c;
if (d >= 0) {
x1r = (-b + sqrt(d)) / (2 * a);
x2r = (-b - sqrt(d)) / (2 * a);
x1i = 0;
x2i = 0;
}
else {
x1r = -b / (2 * a);
x2r = -b / (2 * a);
x1i = sqrt(-d) / (2 * a);
x2i = -x1i;
}
}
And errors that I get with VC++ 6:
Code:
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.c
C:\Homecooked\Tanja\main.c(7) : error C2143: syntax error : missing ')' before '&'
C:\Homecooked\Tanja\main.c(7) : error C2143: syntax error : missing '{' before '&'
C:\Homecooked\Tanja\main.c(7) : error C2059: syntax error : '&'
C:\Homecooked\Tanja\main.c(7) : error C2059: syntax error : ')'
C:\Homecooked\Tanja\main.c(27) : warning C4013: 'sqeq' undefined; assuming extern returning int
C:\Homecooked\Tanja\main.c(64) : error C2143: syntax error : missing ')' before '&'
C:\Homecooked\Tanja\main.c(64) : error C2143: syntax error : missing '{' before '&'
C:\Homecooked\Tanja\main.c(64) : error C2059: syntax error : '&'
C:\Homecooked\Tanja\main.c(64) : error C2059: syntax error : ')'
Error executing cl.exe.
main.exe - 8 error(s), 1 warning(s)
Thanks
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|