I have this program, this is giving junk/garbage values in output:
Statement: take input from user in first 3 columns of each row.add these 3 columns and print out on 4th column and check weather number is even or odd, if even place 0 on 5th column.
sorry for my english.
#include <iostream>
#include <string>
#include <cstdlib>
usingnamespace std;
int main()
{
int a[5][5], i, j, sum, k, l;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<< "Enter the value of A [" << i << "][" <<j << "] :-";
cin >> a[i][j];
}
}
for(k=0;k<3;k++)
{
sum=a[k][0]+a[k][1]+a[k][2]; // sum equals first three array values
a[k][3]=sum; // Assign sum to 4th place in array
}
for(k=0;k<3;k++)
{
if(a[k][3]%2==0)
a[k][4] = 0;// Assign a 0, if even, in 5th place
else
a[k][4] = 1; // if not even, assign a 1, in 5th place
}
cout << "Column 1 Column 2 Column 3 The Totals Odd = 1 / Even = 0" << endl;
for(i=0;i<3;i++)
{
cout<< " " <<a[i][0] << "\t\t " <<a[i][1] << "\t\t " <<a[i][2] << "\t\t " << a[i][3] << "\t\t "<<a[i][4] << endl;
// Print out each array values, under the appropriate headings
}
system("Pause");
system("CLS");
}