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

By Suraj Chaudhary

<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();
}

Suraj Chaudhary is a writer, developer, founder, and a constant learner. He shares lessons and resource to living a fuller life every week. On this blog, he shares helpful guides and helpful articles that help his 70,000+ monthly readers find answers, solve problems, and meet their curious needs.

Leave a Comment

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