WAP to store salary, name, age of 5 person on “person.txt” file.

5/5 - (1 vote)
<span role="button" tabindex="0" data-code="#include<stdio.h> #include<conio.h> void main() { FILE *fp; int salary; char name[25]; int age,i; clrscr(); fp=fopen("person.txt","w"); for(i=0;i
#include<stdio.h>
#include<conio.h>
void main()
{
	FILE *fp;
	int salary;
	char name[25];
	int age,i;
	clrscr();
	fp=fopen("person.txt","w");
for(i=0;i<5;i++)
{
	printf("Enter your salary:\n");
	scanf("%d",&salary);
	printf("Enter your name:\n");
	scanf("%s",name);
	printf("Enter your age:\n");
	scanf("%d",&age);
	fprintf(fp,"%d\n%s\n%d\n",salary,name,age);
}
	fclose(fp);
	getch();
}
Sharing Is Caring:

Leave a Comment

Slide to prove you're not a bot/spammer *