yes its possible... i didnt much time here it is... saved in filename as Trainee.txt
#include <stdio.h>
#include <conio.h>
int main()
{
FILE *fp;
fp = fopen("trainee.txt","w");
long int num;
int count,n,i,j;
printf("\nEnter How many trainees?");
scanf("%d",&n);
fprintf(fp, "%s %d \n", "The total number of Trainees are :",n );
for(count=1;count<=n;++count)
{
printf("\nEnter last 8 digit of Hall ticket number:");
scanf("%ld",&num);
fprintf(fp,"%s %d \n", "Hall ticket number :", num);
if (count<40)
{
printf("Enter the computer Table number ST-");
scanf("%d",&i);
fprintf(fp,"%s %d \n", "count :", i);
printf("%d",count);
printf(" Hall Ticket Number 2018%ld",num);
printf("\tST-%d",i);
}
else
{
printf("Enter the computer Table number PD-");
scanf("%d",&j);
fprintf(fp,"%s %d \n", "Computer table number", j);
printf("%d",count);
fprintf(fp,"%s %d \n", "count :", i);
printf(" Hall Ticket Number 2018%ld",num);
printf("\tPD-%d",j);
fprintf(fp,"\n\n-----------------------\n");
}
fclose(fp);
getch();
}
return 0;
}