-->
Showing posts with label name and percentage of some students from a data file. Show all posts
Showing posts with label name and percentage of some students from a data file. Show all posts

Program to read roll,name and percentage of some students from a data file

using codeblocks
-----------------------------------------------------------------------------------------
//reading data from a data file
#include<stdio.h>
#include<conio.h>
int main()
{
FILE *k;                                     //  pointer for file declaration
char name[30],choice;                        //identifier declaration
int roll;                                          //       "             "
float per;
k=fopen("student.txt","r");          //opening of file in write mode
printf("records are\n");
while((fscanf(k,"%d %f %s",&roll,&per,name))!=EOF)//inputs goes until the file ends(End of File)
{
printf("roll=%d per=%f name=%s\n",roll,per,name);   //printing on screen
}
printf("\n reading process completed successfully\n");
fclose(k);                                       //closing data file
getch();
return 0;
}


---------------------------------------------------------------------------------------------------
using turboc++
----------------------------------------------------------------------------------------------------------
//reading data from a data file
#include<stdio.h>
#include<conio.h>
int main()
{
FILE *k;                                     //  pointer for file declaration
char name[30],choice;                        //identifier declaration
int roll;                                          //       "             "
float per;
k=fopen("student.txt","r");          //opening of file in write mode
printf("records are\n");
while((fscanf(k,"%d %f %s",&roll,&per,name))!=EOF)//inputs goes until the file ends(End of File)
{
printf("roll=%d per=%f name=%s\n",roll,per,name);   //printing on screen
}
printf("\n reading process completed successfully\n");
fclose(k);                                       //closing data file
getch();
return 0;
}