Answer to Question #207197 in C for Ali khan

Question #207197

Write a program which generates the table of a number given by user and then write 

the table in a file named “table.dat”.


1
Expert's answer
2021-06-15T07:08:23-0400
#include <stdio.h>


int main()
{
    int n;
    printf("Enter a number: ");
    scanf("%d", &n);
    FILE *fptr;
    fptr = fopen("table.dat","w");


    if(fptr == NULL)
       {
          printf("Error!");   
       }


   fprintf(fptr,"%d",n);
    for(int i=1;i<=12;i++){
        int m=i*n;
        fprintf(fptr,"%d x %d = %d \n",i,n,m);
    }
    fclose(fptr);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS