problem

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i=10;
float a[150], n;
do
(a[1])=(float)i-(1/a[i+2]);
n=a[i];
i=i-2;
}
while (i>=1);
y=1/n
printf("skaicius yra &d.2",y);
system ("pause");
return 0

in 10 line(n=a[i];) it says: expected 'while before "n"
expected '('before "n"
expected ')' before ';' token

anyone knows whats the problem?
You forgot the '{' after do.
i got the answer 1.#info.. what's wrong?

can you check your pm?
This code compiles and gives answer 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdio>
#include <cstdlib>
#include <cmath>

int main()
{
	int i = 10;
	float a[ 150 ], n;

	do
	{
		a[ 1 ] = ( float ) i - ( 1 / a[ i + 2 ] );
		n = a[ i ];
		i = i - 2;
	} while ( i >= 1 );

	float y = 1 / n;
	printf( "skaicius yra &d.2", y );
	system( "pause" );

	return 0;
}
Last edited on
#include <cstdio>
#include <cstdlib>
#include <cmath>

int main()
{
int i = 10;
float a[ 150 ], n;

do
{
a[ 1 ] = ( float ) i - ( 1 / a[ i + 2 ] );
n = a[ i ];
i = i - 2;
} while ( i >= 1 );

float y = 1 / n;
printf( "skaicius yra %f", y );
system( "pause" );

return 0;
}

it gives answer 1.#Info. your gave 2 coz it had ".2" on answer
Topic archived. No new replies allowed.