I'm new here so im not sure how this works and i apologise if i wrote anything wrong but the question is:
Read 25 integers entered via keyboard and store them in a file "num.dat". Next, read the file and store the values in an array;
double all the values in the odd positions and add 3 to the even positions in the array. Write the new values to another file, "endin.dat".
This is what i have an its obviously not working, can someone help me please.
Code:
#include<stdio.h>
int main (void){
int num[25];
int n;
int sum1;
int sum2;
n=num[25];
FILE * original = fopen("num.dat","w");
printf("Enter 25 numbers:\n", num[25]);
if (n%2==1){
sum1=n*2;
printf("Doubled odd numbers are %d\n",num[25]);
}
else {
sum2=n+3;
printf("Addition of three to even numbers %d\n", num[25]);
}
FILE * new = fopen("endin.dat","r");
fclose(original);
fclose(new);
return 0;
}