Use of static key world in c++


i am writing this a program in which i want to calculate the total bill of different products buy by customer. For this purpose i use static key world but it is not working.
My Code Is as Follow:
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
 
if((ct=='e' || ct=='E')&& (len==1))
   {
        system("cls");
    cout<<'\n';
    cout<<'\n';
    cout<<'\n';
      cout<<"         ! NEW__CUSTOMER_ENTRY !";cout<<'\n';
      cout<<"          ======================";
     cout<<'\n';
     cout<<'\n';
     cout<<'\n';
     cout<<'\n';
     cout<<"Enter Name of Custmer :: ";
     cin>>nam;
     size=strlen(nam);
     infile.seekp(92,ios::beg);
     infile.write(nam,size); 
     cout<<'\n'; 
     cout<<'\n';
     cout<<'\n';
     cout<<'\n';
     cout<<"Enter No of Different Itmes Buy :: ";
     cin>>no;  
     while(j<=no)
     {
     cout<<'\n'; 
     cout<<'\n';
     cout<<'\n'; 
     cout<<"Enter Per Unit Price of ";cout<<j;cout<<" Item :: ";
     cin>>pri;
    cout<<'\n'; 
     cout<<'\n';
     cout<<'\n';
     cout<<"Enter No Of Itmes :: ";
     cin>>qno;cout<<'\n'; 
     cal=pri*qno;  ////cal is static////             
     cout<<cal;         
          j++;    
     }
cout<<cal2=cal+cal;

It just add up the last calculation.
alto in STATIC variable previous value is save but in this case it is not working?
Each time you use the assignment operator you change the value of the variable, it doesn't matter how the variable is stored
Then please tell me how can i do this?
cal=pri*qno; ////cal is static////


The above statement do direct assignment. If you want to add them all up use below.

cal+=(pri*qno);

thnx i solve it
Topic archived. No new replies allowed.