Please find errors in my program

Hi everyone....
I'm trying to make a program to input details of people & display their details as per their mobile numbers which the user inputs
my program:-

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
struct use
{char name [30];
char phone[15];
long amount;
char gender;
}user[15];
void details(use user[],int d)
{int n;
for(int i=0;i<d;i++)
{cout<<"Enter the details of user "<<i+1<<endl;
cout<<"Enter the name :";
gets(user[i].name);
cout<<"Enter the gender of the user :";
cin>>user[i].gender;
cout<<"Enter the bill due :";
cin>>user[i].amount;
cout<<"Enter the mobile number :";
gets(user[i].phone);
cout<<"Your entered details are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone;
cout<<endl<<"Press 4 to continue :";
cin>>n;
if(n==4)
clrscr();
else
{exit (0);}}}
void search(use user[], int d)
{char e[15];
cout<<"Please enter the mobile number you want to search :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
cout<<"The details of the user are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
else
cout<<"Incorrect mobile number";}}
void bill(use user[],long num,int d)
{long a,r;
char e[15];
cout<<"Please enter the mobile number of the user :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
{cout<<"The details of the user are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
user[i].amount=user[i].amount-num;
cout<<"Your due bill is :"<<user[i].amount<<endl;
cout<<"Press 4 to generate a reciept.";
cin>>a;
if(a==4)
{clrscr();
r=user[i].amount-num;
cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"Mobile number :"<<user[i].phone<<endl;
cout<<"Name :"<<user[i].name<<endl;
cout<<"Previous bill :"<<user[i].amount<<endl;
cout<<"Billed amount :"<<num<<endl;
cout<<"#######################################################################";
cout<<"Bill due :"<<r<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
cout<<endl<<endl<<"*********************************************************"<<endl;
cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;}
else
{cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;} }
else if(strcmpi(e,user[i].phone)!=0)
cout<<"Incorrect mobile number";}
void recharge(use user[],long num, int d)
{long r,a;
char e[15];
cout<<"Please enter the mobile number of the user :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
{cout<<"The details of the user are :"<<<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
user[i].amount=user[i].amount+num;
cout<<"Your balance is :"<<user[i].amount<<endl;
cout<<"Press 4 to generate a reciept.";
cin>>a;
if(a==4)
{clrscr();
r=user[i].amount+num;
cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"Mobile number :"<<user[i].phone<<endl;
cout<<"Name :"<<user[i].name<<endl;
cout<<"Previous balance :"<<user[i].amount<<endl;
cout<<"Billed amount :"<<num<<endl;
cout<<"#######################################################################";
cout<<"Current balance :"<<r<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
cout<<endl<<endl<<"*********************************************************"<<endl;
cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;}
else
{exit (0);}}
else if(strcmpi(e,user[i].phone)!=0)
cout<<"Incorrect mobile number";}}}
void main()
{clrscr();
int a,b,n,s,d;
long num;
cout<<"Enter the number of records you want to enter :";
cin>>d;
details(user,d);
clrscr();
label:
cout<<"Select options from below :"<<endl;
cout<<"1.Details"<<endl<<"2.Postpaid"<<endl<<"3.Prepaid"<<"4.Exit"<<endl;
cout<<"Enter your options :";
cin>>n;
clrscr();
if(n==1)
{search(user, d);
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==2)
{cout<<"How much amount you want to pay :";
cin>>num;
bill(user, num,d);
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==3)
{cout<<"How much amount you want to pay :";
cin>>num;
recharge(user, num, d)
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==4)
exit(0);

getch();}
its showing some errors like:-
70:Declaration syntax error
97:Declaration missing
135:Function 'recharge' should have a prototype
136:Statement missing
plz help me resolve them
It will be easier to read if you use code tags.

Here's how: http://www.cplusplus.com/articles/jEywvCM9/

For one thing, main should be a int
void main()

I'm not 100% sure but I'd guess the number "70:Declaration syntax error" is the line number in your code having the problem.

you should have a return 0; at the end of main.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
struct use
{char name [30];
char phone[15];
long amount;
char gender;
}user[15];
void details(use user[],int d)
{int n;
for(int i=0;i<d;i++)
{cout<<"Enter the details of user "<<i+1<<endl;
cout<<"Enter the name :";
gets(user[i].name);
cout<<"Enter the gender of the user :";
cin>>user[i].gender;
cout<<"Enter the bill due :";
cin>>user[i].amount;
cout<<"Enter the mobile number :";
gets(user[i].phone);
cout<<"Your entered details are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone;
cout<<endl<<"Press 4 to continue :";
cin>>n;
if(n==4)
clrscr();
else
{exit (0);}}}
void search(use user[], int d)
{char e[15];
cout<<"Please enter the mobile number you want to search :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
cout<<"The details of the user are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
else
cout<<"Incorrect mobile number";}}
void bill(use user[],long num,int d)
{long a,r;
char e[15];
cout<<"Please enter the mobile number of the user :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
{cout<<"The details of the user are :"<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
user[i].amount=user[i].amount-num;
cout<<"Your due bill is :"<<user[i].amount<<endl;
cout<<"Press 4 to generate a reciept.";
cin>>a;
if(a==4)
{clrscr();
r=user[i].amount-num;
cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"Mobile number :"<<user[i].phone<<endl;
cout<<"Name :"<<user[i].name<<endl;
cout<<"Previous bill :"<<user[i].amount<<endl;
cout<<"Billed amount :"<<num<<endl;
cout<<"#######################################################################";
cout<<"Bill due :"<<r<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
cout<<endl<<endl<<"*********************************************************"<<endl;
cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;}
else
{cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;} }
else if(strcmpi(e,user[i].phone)!=0)
cout<<"Incorrect mobile number";}
void recharge(use user[],long num, int d)
{long r,a;
char e[15];
cout<<"Please enter the mobile number of the user :";
cin>>e;
for(int i=0;i<d;i++)
{if(strcmpi(e,user[i].phone)==0)
{cout<<"The details of the user are :"<<<<endl<<"Name :"<<user[i].name<<endl<<"Gender :"<<user[i].gender<<endl<<"Bill due :"<<user[i].amount<<endl<<"Mobile number :"<<user[i].phone<<endl;
user[i].amount=user[i].amount+num;
cout<<"Your balance is :"<<user[i].amount<<endl;
cout<<"Press 4 to generate a reciept.";
cin>>a;
if(a==4)
{clrscr();
r=user[i].amount+num;
cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
cout<<"Mobile number :"<<user[i].phone<<endl;
cout<<"Name :"<<user[i].name<<endl;
cout<<"Previous balance :"<<user[i].amount<<endl;
cout<<"Billed amount :"<<num<<endl;
cout<<"#######################################################################";
cout<<"Current balance :"<<r<<endl;
cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
cout<<endl<<endl<<"*********************************************************"<<endl;
cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;}
else
{exit (0);}}
else if(strcmpi(e,user[i].phone)!=0)
cout<<"Incorrect mobile number";}}}
void main()
{clrscr();
int a,b,n,s,d;
long num;
cout<<"Enter the number of records you want to enter :";
cin>>d;
details(user,d);
clrscr();
label:
cout<<"Select options from below :"<<endl;
cout<<"1.Details"<<endl<<"2.Postpaid"<<endl<<"3.Prepaid"<<"4.Exit"<<endl;
cout<<"Enter your options :";
cin>>n;
clrscr();
if(n==1)
{search(user, d);
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==2)
{cout<<"How much amount you want to pay :";
cin>>num;
bill(user, num,d);
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==3)
{cout<<"How much amount you want to pay :";
cin>>num;
recharge(user, num, d)
cout<<endl<<"Press 1 to go back :";
cin>>s;
if(s==1)
{clrscr();
goto label;}
else
exit (0);}
else if(n==4)
exit(0);

getch();}
Isn't that hard to read? No wonder it's filled with syntax errors: use your tools to help you; don't wait to write your entire program to compile it.

When you ask for help your goal should be to make it as easy as possible for people to help you. Usually asking for someone to "plz fix" is bad etiquette at best. Here is your program, correctly indented, and with (hopefully) syntax errors removed.

I cannot compile your code because I don't have an obsolete compiler installed; your program looks like it was written 25 years ago.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include<iostream.h>
#include<string.h>
#include<cstdlib.h>
#include<stdio.h>

struct use {
  char name [30];
  char phone[15];
  long amount;
  char gender;
}user[15];

void details(use user[],int d) {
  int n;
  for(int i=0;i<d;i++) {
    cout<<"Enter the details of user "<<i+1<<endl;
    cout<<"Enter the name :";
    gets(user[i].name);
    cout<<"Enter the gender of the user :";
    cin>>user[i].gender;
    cout<<"Enter the bill due :";
    cin>>user[i].amount;
    cout<<"Enter the mobile number :";
    gets(user[i].phone);
    cout<<"Your entered details are :" <<endl
        <<"Name :" <<user[i].name <<endl
        <<"Gender :" <<user[i].gender <<endl
        <<"Bill due :" <<user[i].amount <<endl
        <<"Mobile number :" <<user[i].phone;

    cout<<endl<<"Press 4 to continue :";
    cin>>n;
    if(n==4)
      clrscr();
    else {
      exit (0);
    }
  }
}

void search(use user[], int d) {
  char e[15];
  cout<<"Please enter the mobile number you want to search :";
  cin>>e;
  for(int i=0;i<d;i++) {
    if(strcmpi(e,user[i].phone)==0)
      cout<<"The details of the user are :" <<endl
          <<"Name :" <<user[i].name <<endl
          <<"Gender :" <<user[i].gender <<endl
          <<"Bill due :" <<user[i].amount <<endl
          <<"Mobile number :" <<user[i].phone <<endl;
    else
      cout<<"Incorrect mobile number";
  }
}

void bill(use user[],long num,int d) {
  long a,r;
  char e[15];
  cout<<"Please enter the mobile number of the user :";
  cin>>e;
  for(int i=0;i<d;i++) {
    if(strcmpi(e,user[i].phone)==0) {
      cout<<"The details of the user are :" <<endl
          <<"Name :" <<user[i].name <<endl
          <<"Gender :" <<user[i].gender <<endl
          <<"Bill due :" <<user[i].amount <<endl
          <<"Mobile number :" <<user[i].phone <<endl;

      user[i].amount=user[i].amount-num;

      cout<<"Your due bill is :"<<user[i].amount<<endl;
      cout<<"Press 4 to generate a reciept.";
      cin>>a;

      if(a==4) {
        clrscr();
        r=user[i].amount-num;
        cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
        cout<<"Mobile number :"<<user[i].phone<<endl;
        cout<<"Name :"<<user[i].name<<endl;
        cout<<"Previous bill :"<<user[i].amount<<endl;
        cout<<"Billed amount :"<<num<<endl;
        cout<<"#######################################################################";
        cout<<"Bill due :"<<r<<endl;
        cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
        cout<<endl<<endl<<"*********************************************************"<<endl;
        cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;
      } else {
        cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;
      }
    }
    else if(strcmpi(e,user[i].phone)!=0)
      cout<<"Incorrect mobile number";
  }
}
void recharge(use user[],long num, int d) {
  long r,a;
  char e[15];
  cout<<"Please enter the mobile number of the user :";
  cin>>e;
  for(int i=0;i<d;i++) {
    if(strcmpi(e,user[i].phone)==0) {
      cout<<"The details of the user are :" <<endl
          <<"Name :" <<user[i].name <<endl
          <<"Gender :" <<user[i].gender <<endl
          <<"Bill due :" <<user[i].amount <<endl
          <<"Mobile number :" <<user[i].phone <<endl;

      user[i].amount=user[i].amount+num;

      cout<<"Your balance is :"<<user[i].amount<<endl;
      cout<<"Press 4 to generate a reciept.";
      cin>>a;
      if(a==4) {
        clrscr();
        r=user[i].amount+num;
        cout<<"^^^^^^^^^^^^^^TELEANDROMEDA^^^^^^^^^^^^^^^^^^^^^"<<endl;
        cout<<"Mobile number :"<<user[i].phone<<endl;
        cout<<"Name :"<<user[i].name<<endl;
        cout<<"Previous balance :"<<user[i].amount<<endl;
        cout<<"Billed amount :"<<num<<endl;
        cout<<"#######################################################################";
        cout<<"Current balance :"<<r<<endl;
        cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
        cout<<endl<<endl<<"*********************************************************"<<endl;
        cout<<"THANK YOU FOR USING TELEANDROMEDA"<<endl;}
      else {
        exit (0);
      }
    } else if(strcmpi(e,user[i].phone)!=0)
      cout<<"Incorrect mobile number";
  }
}

int main() {
  clrscr();
  int a,b,n,s,d;
  long num;
  cout<<"Enter the number of records you want to enter :";
  cin>>d;
  details(user,d);
  clrscr();
 label:
  cout<<"Select options from below :"<<endl;
  cout<<"1.Details"<<endl<<"2.Postpaid"<<endl<<"3.Prepaid"<<"4.Exit"<<endl;
  cout<<"Enter your options :";
  cin>>n;
  clrscr();
  if(n==1) {
    search(user, d);
    cout<<endl<<"Press 1 to go back :";
    cin>>s;
    if(s==1) {
      clrscr();
      goto label;
    }
    else
      exit (0);}
  else if(n==2) {
    cout<<"How much amount you want to pay :";
    cin>>num;
    bill(user, num,d);
    cout<<endl<<"Press 1 to go back :";
    cin>>s;
    if(s==1) {
      clrscr();
      goto label;
    }
    else
      exit (0);
  }
  else if(n==3) {
    cout<<"How much amount you want to pay :";
    cin>>num;
    recharge(user, num, d);
      cout<<endl<<"Press 1 to go back :";
    cin>>s;
    if(s==1) {
      clrscr();
      goto label;
    }
    else
      exit (0);
  }
  else if(n==4)
    exit(0);
}

Topic archived. No new replies allowed.