# error in the line 25, A Statement!

• (2 Pages)
• 1
• 2

## 21 Replies - 1219 Views - Last Post: 08 October 2013 - 10:26 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=330994&amp;s=816aa337508d94dc89841ecc82f86ed4&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

# error in the line 25, A Statement!

Posted 07 October 2013 - 10:03 PM

hey everyone, have a problem with the following program:
```#include <math.h>
#include <stdio.h>

#define PI  3.1415926535897932384626433832795
#define N   30

int main()
{
// Delvare two arrays to hold the coordinates of initial data points
double x[N], y[N],(x2);
int i;

// Generate the points
double xx = PI/2;
double step = 2 * PI / (N - 1);

for ( i = 0; i < N; ++i, xx += step)
{
double x2=xx+sin(xx);   // vary x spacing
x[i] = x2;
y[i] = sin(x2)/x2;
}

// Initialize the regression approximation routine with known data points
A.getValue(N, x, y, 3);

// Interrogate the regression function to find approximated values
int N_out =50;
xx = PI/2 ;
step = 2 * PI / (N_out - 1);

printf("\nx, exact, discrete_3,  discrete_5,  discrete_10");

for ( i = 0; i < N_out; ++i, xx += step)
{
double x2=xx+sin(xx);
printf("\n%.4lf, %.6lf, %.6lf, %.6lf, %.6lf", x2, sin(x2)/x2, A.getValue(x2));
}
return 0;

```

This post has been edited by Skydiver: 07 October 2013 - 10:04 PM
Reason for edit:: Put code in code tags. Learn to follow instructions.

Is This A Good Question/Topic? 0

## Replies To: error in the line 25, A Statement!

### #2 Skydiver

• Code herder

Reputation: 3965
• Posts: 12,614
• Joined: 05-May 12

## Re: error in the line 25, A Statement!

Posted 07 October 2013 - 10:08 PM

What is the error that you are getting?

Perhaps if you included "discrete.h" like it did in http://www.codecogs....on/discrete.php you would have more success.

### #3 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 07 October 2013 - 10:34 PM

the error is: request for member 'getValue' in something not a structur or union. in line 25 and 39 where getValue is appeared.

### #4 eker676

• Software Engineer

Reputation: 378
• Posts: 1,833
• Joined: 18-April 09

## Re: error in the line 25, A Statement!

Posted 07 October 2013 - 11:02 PM

What is A?

You have not defined it anywhere and it's not defined in the standard library. Define the A structure.

Lets say that A is defined. That is still the incorrect syntax. You must first create an object for the function to operate on. Also, getValue() is not defined. In C you can access the members of a struct with . (dot) notation. i.e. A.value = 10

### #5 Skydiver

• Code herder

Reputation: 3965
• Posts: 12,614
• Joined: 05-May 12

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 05:42 AM

After missing the #include, it also looks like he missed the declaration of variables A, B, and C:
```  // Initialize the regression approximation routine with known data points
Maths::Regression::Discrete A(N, x, y, 3);
Maths::Regression::Discrete B(N, x, y, 5);
Maths::Regression::Discrete C(N, x, y, 10);

```

### #6 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 04:01 PM

Skydiver, on 08 October 2013 - 05:42 AM, said:

After missing the #include, it also looks like he missed the declaration of variables A, B, and C:
```  // Initialize the regression approximation routine with known data points
Maths::Regression::Discrete A(N, x, y, 3);
Maths::Regression::Discrete B(N, x, y, 5);
Maths::Regression::Discrete C(N, x, y, 10);

```

so i changed the program as following: i defined A, and declared get value! i have still troubles in this code!
```#include <math.h>
#include <stdio.h>

#define PI  3.1415926535897932384626433832795
#define N   20

#define A ( 	int	n, double	x,double	y,int	degree	 )

int main()
{
double x[N], y[N], getValue(float);
int i;

double xx = PI/2;
double step = 2 * PI / (N - 1);

for ( i = 0; i < N; ++i, xx += step)
{
double x2=xx+sin(xx);
x[i] = x2;
y[i] = sin(x2)/x2;
}

A ( N, x, y, 3);

int N_out =50;
xx = PI/2 ;
step = 2 * PI / (N_out - 1);

printf("\n x, exact, discrete_3");

for ( i = 0; i < N_out; ++i, xx += step)
{
double x2=xx+sin(xx);
printf("\n%.4lf, %.6lf, %.6lf", x2, sin(x2)/x2,getValue(x2));
}
return 0;
}

```

This post has been edited by Skydiver: 08 October 2013 - 07:55 PM
Reason for edit:: Put code in code tags. Learn to follow instructions.

### #7 Skydiver

• Code herder

Reputation: 3965
• Posts: 12,614
• Joined: 05-May 12

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 07:55 PM

### #8 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 08:55 PM

Skydiver, on 08 October 2013 - 07:55 PM, said:

/>

what would this change in the code?

### #9 jimblumberg

Reputation: 4565
• Posts: 14,417
• Joined: 25-December 09

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 08:58 PM

Quote

what would this change in the code?

It'll make your code readable! And if you don't start using code tags, you'll find your topics closed!

Jim

### #10 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:08 PM

jimblumberg, on 08 October 2013 - 08:58 PM, said:

Quote

what would this change in the code?

It'll make your code readable! And if you don't start using code tags, you'll find your topics closed!

Jim

i did it! but dosn't work and appears the error expected identier or '(' befor'[' taken.

or whats the right way to do it?

### #11 jimblumberg

Reputation: 4565
• Posts: 14,417
• Joined: 25-December 09

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:12 PM

Quote

i did it!

You did what, exactly?

Quote

but dosn't work

Why doesn't it work? You need to ask specific questions and if you're getting error messages post the complete error messages exactly as they appear in your development environment.

Jim

### #12 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:17 PM

jimblumberg, on 08 October 2013 - 09:12 PM, said:

Quote

i did it!

You did what, exactly?

Quote

but dosn't work

Why doesn't it work? You need to ask specific questions and if you're getting error messages post the complete error messages exactly as they appear in your development environment.

Jim

jim i put my code in code tags! and the error what i postet was the only error that appears!

### #13 jimblumberg

Reputation: 4565
• Posts: 14,417
• Joined: 25-December 09

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:23 PM

Quote

and the error what i postet was the only error that appears!

That is not the complete error message. Error messages have much more information embedded within them, such as the line numbers where the problems were detected.

For example when I compile your code I get these messages:

Quote

||=== c_homework, Debug ===|
main.c||In function ‘main’:|
main.c|8|error: expected ‘)’ before ‘n’|
main.c|25|note: in expansion of macro ‘A’|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|8|warning: statement with no effect [-Wunused-value]|
main.c|25|note: in expansion of macro ‘A’|
main.c|12|warning: variable ‘y’ set but not used [-Wunused-but-set-variable]|
main.c|12|warning: variable ‘x’ set but not used [-Wunused-but-set-variable]|
||=== Build finished: 1 errors, 6 warnings (0 minutes, 1 seconds) ===|

And with these messages, please explain what your trying to accomplish on line 8.

Jim

This post has been edited by jimblumberg: 08 October 2013 - 09:26 PM

### #14 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:28 PM

jimblumberg, on 08 October 2013 - 09:23 PM, said:

Quote

and the error what i postet was the only error that appears!

That is not the complete error message. Error messages have much more information embedded within them, such as the line numbers where the problems were detected.

Jim

yes, your'e right. the line number where the problem is detectet ist 8. to be honest i don't know how to use code tags! so my code it jet not readable!

### #15 siri86

Reputation: -1
• Posts: 12
• Joined: 07-October 13

## Re: error in the line 25, A Statement!

Posted 08 October 2013 - 09:36 PM

jimblumberg, on 08 October 2013 - 09:23 PM, said:

Quote

and the error what i postet was the only error that appears!

That is not the complete error message. Error messages have much more information embedded within them, such as the line numbers where the problems were detected.

For example when I compile your code I get these messages:

Quote

||=== c_homework, Debug ===|
main.c||In function main:|
main.c|8|error: expected ) before n|
main.c|25|note: in expansion of macro A|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|25|warning: left-hand operand of comma expression has no effect [-Wunused-value]|
main.c|8|warning: statement with no effect [-Wunused-value]|
main.c|25|note: in expansion of macro A|
main.c|12|warning: variable y set but not used [-Wunused-but-set-variable]|
main.c|12|warning: variable x set but not used [-Wunused-but-set-variable]|
||=== Build finished: 1 errors, 6 warnings (0 minutes, 1 seconds) ===|

And with these messages, please explain what your trying to accomplish on line 8.

Jim

i try to define the function A in the line 8. this function Initializes the regression approximation routine with known data points