Problem polega na tym ze u mnie ten pogram sie nie kompiluje tylko wywala bledy. mam takie bledy:
4 D:\Dev-Cpp\main.c syntax error before '&' token
D:\Dev-Cpp\main.c In function `Dane':
7 D:\Dev-Cpp\main.c `n' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
At top level:
10 D:\Dev-Cpp\main.c syntax error before '&' token
D:\Dev-Cpp\main.c In function `Oblicz':
14 D:\Dev-Cpp\main.c 'for' loop initial declaration used outside C99 mode
14 D:\Dev-Cpp\main.c `n' undeclared (first use in this function)
D:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1
a oto kod zrodlowy:
#include <stdio.h>
#include <conio.h>
void Dane (int &n)
{
printf("Podaj n: ");
scanf("%d",&n);
}
float Oblicz (int &n)
{
float s1=1;
int s2=0, k2=1;
for (int i=1;i<=n;i++)
{
k2*=i;
s1*=1./4;
s2-=k2;
}
return s1/s2;
}
int main (void)
{
int n;
Dane(n);
printf("wynik = %.4f",Oblicz(n));
getch();
return 0;
}
-----------------------------------------------------------------------------
Prosze jeli Ktos moze niech to sprawdzi ja juz nie mam sily na to. Z gory dziekuje.
4 D:\Dev-Cpp\main.c syntax error before '&' token
D:\Dev-Cpp\main.c In function `Dane':
7 D:\Dev-Cpp\main.c `n' undeclared (first use in this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
At top level:
10 D:\Dev-Cpp\main.c syntax error before '&' token
D:\Dev-Cpp\main.c In function `Oblicz':
14 D:\Dev-Cpp\main.c 'for' loop initial declaration used outside C99 mode
14 D:\Dev-Cpp\main.c `n' undeclared (first use in this function)
D:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1
a oto kod zrodlowy:
#include <stdio.h>
#include <conio.h>
void Dane (int &n)
{
printf("Podaj n: ");
scanf("%d",&n);
}
float Oblicz (int &n)
{
float s1=1;
int s2=0, k2=1;
for (int i=1;i<=n;i++)
{
k2*=i;
s1*=1./4;
s2-=k2;
}
return s1/s2;
}
int main (void)
{
int n;
Dane(n);
printf("wynik = %.4f",Oblicz(n));
getch();
return 0;
}
-----------------------------------------------------------------------------
Prosze jeli Ktos moze niech to sprawdzi ja juz nie mam sily na to. Z gory dziekuje.