John Napier's Algorithm

i am trying to make john napier's algorithm table
can anyone help me in finding the error..
this code is not full
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
/* John Napier's Algorithm */

#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>


struct cards {
       int sqr[2][9];
       };
cards v1[10];
struct depend {
      double power[2];int size[2];
       };
int main() {
    void create_napier_table();
    void display_napier_table();
    depend dependence(int f1,int f2);
    int first,second,temp,first1,second1;
    cout << "Creating John Napier's Table...\n";
    create_napier_table();
    cout << "\n\nEnter 1st no.: ";
    cin >> first;
    cout << "Enter 2nd no.: ";
    cin >> second;
    first1=first;second1=second;
    if (first<second) {
       temp=first;
       first=second;
       second=temp; }
    if (first==0||second==0) { cout << "Result is 0"; getch(); exit(0); }
    depend d1;
    d1=dependence(first,second);
    
    int m=d1.size[0];int n=d1.size[1];
    int arr[n][m];
    int n1,n2,n3,n4,i=0,j=0,row=0,coloumn=0;
    while(first>0) {
    n1=int (first / int (d1.power[0]));
    second=second1;
    while(second>0) {
    n2=second%10;
     v1[n1].sqr[0][n2-1]=0;
     v1[n1].sqr[1][n2-1]=0;
     display_napier_table();
    row++;coloumn++;
    second=second/10;
    j+=2; }
    i++;
    d1.power[0]=d1.power[0]/10;
    first=first1-first; }
    for (int i=0;i<row;i++) { cout << "\n"; 
    for (int j=0;j<coloumn;j++)
    cout << arr[j][i] << "\t";    
}
    
        getch();
}
/* Napier's Table */
void create_napier_table() {
    int card_no=0;
    int no,c,d,count=0;
    for (int i=0;i<10;i++,card_no++) { no=1;
    for (int k=0;k<9;k++,no++,count++) {
    d=c=card_no*no;
    if (c<10) {
               v1[i].sqr[0][k]=0;
         v1[i].sqr[1][k]=c; }
         else {
              c=c/10;
    v1[i].sqr[0][k]=c;
    d=d%10;
    v1[i].sqr[1][k]=d; } 
     }
     }
     system("cls");
     
}


//Depencence
depend dependence(int f1,int f2) {
       int a=0,b=0;
       double c,d;
       depend d2;
       while(f1>0) { f1=f1/10; a++; }
       while(f2>0) { f2=f2/10; b++; }
       c=pow(10,(a-1));
       d=pow(10,(b-1));
       d2.size[0]=a;
       d2.size[1]=b;
       d2.power[0]=c;
       d2.power[1]=d;
       return (d2);
       }

void display_napier_table() {
cout << "\t\t\tJohn Napier's Multiplication table\n";
     cout << "\n  ===========================================================================";
     cout << "\n0  0";
     for (int i=1;i<=9;i++)
     cout << setw(8) << i;
     cout << "\n  ===========================================================================";
     for (int i=0;i<9;i++) { cout << "\n";
     cout << i+1 << " ";
     for (int j=0;j<10;j++)
     cout << v1[j].sqr[0][i] << v1[j].sqr[1][i] << "  |\t";
     cout << "  ---------------------------------------------------------------------------"; }
}
Topic archived. No new replies allowed.