#include <stdio.h>
#include <stdlib.h>
float suma(float n)
{
float suma=0.0;
float x=1.00;
float a=0.000;
while(x<=n)
{
suma=suma+(1/(x*(x+1)*(x+2)));
x++;
}
return suma;
}
float n=1.0;
main()
{
n=10;
printf("Suma %f poczatkowych wyrazow %f\n",n,suma(n));
printf("roznica pomiedzy suma n wyrazow a suma podana powyzej: %f\n ",0.25-suma(n)) ;
n=100;
printf("Suma %f poczatkowych wyrazow %f\n",n,suma(n));
printf("roznica pomiedzy suma n wyrazow a suma podana powyzej: %f\n ",0.25-suma(n)) ;
n=1000;
printf("Suma %f poczatkowych wyrazow %f\n",n,suma(n));
printf("roznica pomiedzy suma n wyrazow a suma podana powyzej: %f\n ",0.25-suma(n)) ;
system("pause");
return 0;
}
Mam problem ze skompilowaniem powyższego programu w unixie. Kompilując w Dev C++ wszystko działa. W unixie kompilując komedną gcc pojawia sie komunikat.
z41.c: In function `main':
z41.c:20: error: missing terminating " character
z41.c:21: error: missing terminating " character
z41.c:22: error: syntax error before ';' token
z41.c:24: error: missing terminating " character
z41.c:25: error: missing terminating " character
z41.c:26: error: syntax error before ';' token
z41.c:28: error: missing terminating " character
z41.c:29: error: missing terminating " character
z41.c:30: error: syntax error before ';' token
Co jest nie tak?