Write a C program Write a program using a for loop to put th
Write a C program
Write a program using a for loop to put the following numbers to a file named record. dat. 1 2 3 4 5 6 7 8 9 10Solution
#include<stdio.h>
 int main(){
 FILE *fp;
 int i;
 fp=fopen(\"record.dat\",\"w\");
 for(i=1; i<=10; i++)
 fprintf(fp, \"%d \", i);
 fclose(fp);
 printf(\"Data has been written to the file\ \");
 return 0;
 }
Output:
record.dat
1 2 3 4 5 6 7 8 9 10

