Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- float suma(float tab[], int a, int b){
- float s=0;
- for(;a<b;a++)
- s=s+tab[a];
- return s;
- }
- int main(){
- FILE*we;
- int n=0,dane[100];
- we=fopen("dane.txt","r");
- if(we){
- int x;
- int y;
- int i,n=0;
- while(!feof(we))
- fscanf(we,"%d",&dane[n++]);
- fclose(we);
- printf("oto liczby z pliku: \n");
- for(i=1;i<=n;i++){
- printf("%d ",dane[i-1]);
- }
- printf("\nsuma tych liczb wynosi: %d \n",suma(dane, 0, n));
- }
- else printf("nie moge otworzyc pliku");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement