We provide Engineering,HSEB notes, tutorials which can be helpful for students during college life.
Tuesday, April 7, 2015
47. Write a program to enter"name", "roll-no" and "marks" of 10 students and stores them in a file.Read and display the same from the file.
#include <stdio.h>
#include <conio.h>
struct student
{
char name[30];
int roll,marks;
l }S[10];
void main()
{
int i;
FILE *ptr;
clrscr();
ptr=fopen("student.txt","w+");
printf("\n Input following information’s:- ");
for(i=0;i<l0;i++)
{
fflush(stdin);
printf("\n Name[%d]:-",i+l);
gets(s[i].name);
printf("\n Roll Number[%d]:- ",i+l);
scanf("%d",&s[i].roll);
printf ("\n Marks [%d] :- ",i+1);
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);
printf("\n Name \t Roll \t Marks");
for(i=O;i<n;i++)
printf("\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