Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //author: Anik Sarker
- //date: Feb 20, 2020
- int main()
- {
- FILE *file; //file pointer
- int num;
- //file directory, and file mode
- file = fopen("multiplication table.txt","w");
- if(file == NULL) //check file exist or not
- {
- printf("File doesn't exist");
- }
- else
- {
- printf("File is opened\n");
- printf("Enter number who's multiplication table you want: ");
- scanf("%d", &num);
- fprintf(file, " Multiplaction table of %d \n", num);
- fprintf(file, " ------------------------- \n", num);
- for(int i=1; i<=10; i++){
- fprintf(file," %d * %d = %d\n",num, i, num * i);
- }
- printf("File is written successfully\n");
- //file close
- fclose(file);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement