Site icon Pathshala Nepal

Program to enter a name, roll number, and marks of students

Write a program to enter name, roll number and marks of 10 students and store them in the file.


1 Answer


#include<stdio.h>
#include<conio.h>
void main()
{
     char name[20];
      int roll,mark,i;
      FILE *fp;
      clrscr();
      fp=fopen("student.txt", "a");
      for(i=0;i<10;i++) 
      {
            print("Input name, roll no and marks of a student");
            scanf("%s%d%d",name,roll,&mark); 
            fprintf(fp, "%s%d%d",name,roll,mark);   
       }
        fclose(fp);
        getch(); 
}    


Topics from Computer
Related Questions