can somebody help me on this....
this is a project of mine in c++
actually this program is not complete yet
i just wanna know how to go back in main function when in a void function
and a proper program code that can close a function properly...
tnx..
main()
{
int a;
gotoxy(30,6);printf("Manila Water Billing System");
gotoxy(20,10);printf("1.DATA ENTRY");
gotoxy(20,12);printf("2.DISPLAY DATA");
gotoxy(20,14);printf("3.ADDING OF DATA");
gotoxy(20,16);printf("4.Close The Program");
gotoxy(20,20);printf("Enter Number : ");
scanf("%d",&a);
switch (a) {
case 1:clrscr();gotoxy(20,24);printf("INPUT");input();break;
case 2:clrscr();gotoxy(20,24);printf("DISPLAY");display();break;
case 3:clrscr();gotoxy(20,24);printf("ADD");add();break;
case 4:clrscr();gotoxy(1,1);printf("CLOSE");break;
default:clrscr();gotoxy(1,1);printf("Wrong Number");break;
}
getch();
exit(0);
}
void input()
{
char Ans='y';
int CN[50];
char Nm[50];
int A,B,C,D;
FILE *file1;
file1=fopen("MANILA WATER","w");
// a=0;
do{
clrscr();
gotoxy(28,6);printf("Manila Water Billing-Input");
gotoxy(20,8);printf("Customer Number :");scanf("%s",&CN);
gotoxy(20,10);printf("Enter Customer's Name :");scanf("%s",&Nm);
gotoxy(20,12);printf("Previous Reading :");scanf("%d",&A);
gotoxy(20,14);printf("Present Reading :");scanf("%d",&B);
C=B-A;
D=12.5*C;
gotoxy(20,16);printf("Total Cubic Meter:%d",C);
gotoxy(20,18);printf("Amount To Be Paid :%d",D);
fprintf(file1,"%s",Nm);
fprintf(file1,"%d",CN);
fprintf(file1,"%d",B,C,D);
gotoxy(20,22);printf("continue [y/n]: ");
scanf("%s",Ans);
{fclose(file1);
break;
}
}while(Ans!='n'||Ans!='n');
gotoxy(20,24);printf("End Of The Program!");
getch();
exit;
}
void add()
{
char Ans='y';
int CN[50];
char Nm[50];
int A,B,C,D;
FILE *file1;
file1=fopen("MANILA WATER","a");
// a=0;
do{
clrscr();
gotoxy(28,6);printf("Manila Water Billing-Input");
gotoxy(20,8);printf("Customer Number :");scanf("%s",&CN);
gotoxy(20,10);printf("Enter Customer's Name :");scanf("%s",&Nm);
gotoxy(20,12);printf("Previous Reading :");scanf("%d",&A);
gotoxy(20,14);printf("Present Reading :");scanf("%d",&B);
C=B-A;
D=12.5*C;
gotoxy(20,16);printf("Total Cubic Meter:%d",C);
gotoxy(20,18);printf("Amount To Be Paid :%d",D);
fprintf(file1,"%s",Nm);
fprintf(file1,"%d",CN);
fprintf(file1,"%d",B,C,D);
gotoxy(20,22);printf("continue [y/n]: ");
scanf("%s",Ans);
{fclose(file1);
break;
}
}while(Ans!='n'||Ans!='n');
gotoxy(20,24);printf("End Of The Program!");
getch();
exit;
}
void display()
{
int x;
char Nm[50];
int CN[50];
int C,D;
FILE *file1;
file1=fopen("MANILA WATER","r");
You don't need "exit". When the closing brace '}' at the end of a function is reached, the function will automatically return and execution will resume at the point immediately after where it was called from.