C Program for appending data to a file

#include<stdio.h>

#include<conio.h>

int main()
{
FILE *fp;
int n1,n2,sum;
printf(“Enter two numbers: “);
scanf(“%d%d”,&n1,&n2);
sum=n1+n2;
printf(“Sum of numbers = %d”,sum);
fp=fopen(“data.txt”,”a”);
fprintf(fp,”\n%d %d %d”,n1,n2,sum);
fclose(fp);
getch();
return 0;
}

Output

C Program for appending to a file

Published by

admin

I am a computer teacher, programmer and web developer