How to take the output into a text document if there are nearly 55 trainees are allotted for attending a exam?

0 votes
asked Jun 16, 2018 by Scaria Atakkamundakkal (120 points)
#include <stdio.h>
#include <conio.h>
int main()
{
long int num;
int count,n,i,j;
printf("\nEnter How many trainees?");
scanf("%d",&n);
for(count=1;count<=n;++count)
{
printf("\nEnter last 8 digit of Hall ticket number:");
scanf("%ld",&num);
if (count<40)
{
printf("Enter the computer Table number ST-");
scanf("%d",&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);
printf("%d",count);
printf(" Hall Ticket Number 2018%ld",num);
printf("\tPD-%d",j);
}
getch();
}
return 0;
}

1 Answer

0 votes
answered Jul 3, 2018 by Vasu Devan (140 points)
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;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...