You are on page 1of 3

#include<stdio.

h>

#include <windows.h>

FILE *trial;

int main(void)

int choice,account;

char name[20];

float balance;

if ((trial=fopen("comsci.txt","a"))==NULL)

printf("file could not be opened");

else

printf("Enter account\n");

scanf("%d",&account);

printf("Enter the name\n");

scanf("%s",name);

printf("Enter the balance\n");

scanf(" %f", &balance);

fprintf(trial,"\tACCOUNT \tNAME \tBALANCE\n");


fprintf(trial,"\t%d %s %.2f\n",account,name, balance);

printf("\n\n\t\tWould you like to enter a record?[yes-1/No-2]:\t");

scanf("%d",&choice);

while(choice == 1)

system("cls");

printf("Enter account\n");

scanf("%d",&account);

printf("Enter the name\n");

scanf("%s",name);

printf("Enter the balance\n");

scanf("%4f", &balance);

fprintf(trial,"%d %s %.2f\n",account,name,
balance);

printf("\nEnter Choice[yes-1/No-2]:\n");

scanf("%d",&choice);

}
}

fclose(trial);

You might also like