First, STOP posting in anything except plain text. I can't wade through a sea of formatting junk!
Originally Posted by
Volodya93
Hello! I am struggling with the following question, as a beginner, I would like to ask some help if I may
here is what I've done so far (doesn't work):
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, I, V,R; //using V=I*R ( I=V/R )
FILE *fp;=fopen("data.txt","w");
if(!fp) {
printf("Error opening file\n");
return 1;
}
//get user data into the file
for (i=0;i<10;i++) {
printf("Enter Voltage & Resistance [V R]: ");
fflush(stdout);
scanf("%d %d", &V, &R); //use & for numbers, here
fprintf(fp,"%d %d\n", V, R); //no &'s here
}
fclose(fp);
//now re-open that file for reading - "r" mode, read in the two
//values that user gave, for each of the 10 sets of data.
//and calculate the I value,
}
Don't add any variables you don't need. Don't change the names of the variables from what the instructions request.
Simple isn't just good in programming - it's damn near divine.