HELP for Validation code

i need help for validation code on my source code.
i wanna ask for validation code the user can't input word in this code
thanks before

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
#include <iostream>
#include <conio.h>
#include <iomanip>

using namespace std;
int main()
{

            int matrixA[2][2],matrixB[2][2],X[2][2],a,b,c;

            cout<<"\t\t\tProgram perkalian dua buah matriks\n\n\n";
            cout<<"input angka untuk matrik A : \n";
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    cout<<"Elemen ke "<<(a+1)<<","<<(b+1)<<" : ";
                                    cin>>matrixA[a][b];
                        }
            }

            cout<<"\nMatrik A : \n";
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    cout<<setw(5)<<matrixA[a][b];//setw = jarak matrix a
                        }
                        cout<<endl<<endl;
            }

            cout<<"input angka untuk matrik B : \n";
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    cout<<"Elemen ke "<<(a+1)<<","<<(b+1)<<" : ";
                                    cin>>matrixB[a][b];
                        }
            }
            cout<<"\nMatrik B : \n";
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    cout<<setw(5)<<matrixB[a][b];
                        }
                        cout<<endl;
            }
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    X[a][b]=0;
                                    for (c=0; c<2; c++)
                                    {
                                                X[a][b] += matrixA[a][c] * matrixB[c][b];
                                    }
                        }
            }
            cout<<"\nHasil perkaliannya adalah : \n";
            for(a=0; a<2; a++)
            {
                        for(b=0; b<2; b++)
                        {
                                    cout<<setw(5)<<X[a][b];
                        }
                        cout<<endl;
            }
            cout<<endl;
            getch();

            }
Last edited on
Topic archived. No new replies allowed.