We provide Engineering,HSEB notes, tutorials which can be helpful for students during college life.
Wednesday, April 8, 2015
30. Write program to enter name,roll no and marks 0f 10 students and store them in the file.
#include<stdio.h>
#include<conio.h>
struct student
{
Char name[30];
int roll,marks;
}S{10];
void main()
{
int i;
FILE *ptr;
clrscr();
ptr=fopen("student.txt“,"w+");
printf("\n Input following information’s:- ");
for(i=0;i<10;i++)
{
fflush(stdin);
printf("\n Name[%d]:- ",i+1);
gets(s[i].name):
printf("\n Roll Number[%d]:- ",i+l)i
scanf("%d",&s[i].roll);
printf("\n Marks[%d]:- ",i+l);
scanf("%d",&s[i].marks);
}
for(i=0;i<10;i++)
fprintf(ptr,"\n%s\t%d\%d",s[i].name,s[i].roll,s[i].marks);
fclose(ptr);
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment