i need help din adding the elements of the 2 column. the out of the 2nd column should be 2(bcos 1+1). add the values of each cell(sum =2). how to add the elements of a column. the loop should move down the column and add the values
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
char text[6][6];
ifstream stream1("c:\\cpptestdata.txt");
if(!stream1)
{
cout<<"Cannot read file\n";
}
while(!stream1.eof())
{
for(int i=0; i<6; i++)
{
for(int j=0; j<6; j++)
{
stream1>>text[i][j];
}
}
}
//checking if it has been correctly inserted.
for(int i=0; i<6; i++)
{
for(int j=0; j<6; j++)
{
cout<<text[i][j]<<"\t";
}
cout<<"\n";
}
cout<<"first two rows:"<<endl;
int i,j;
for (i=0; i<2; i++){
for (j=0; j<6; j++){
std::cout<<text[i][j]<<"\t"<<' ';
}cout<<endl;
}
cout<<"find immediate neighbours of A:"<<endl;
char largest=text[1][1];
for(i=0; i<6; i++){
for(j=1; j<2; j++){
if(text[i][j]>largest)
cout<<text[i][0]<<"N"<<"\t";
else
cout<<"0";
}cout<<endl;
}
cout <<" finding k neighbours for A : "<<endl;
for (i=1; i<6; i++){
int max = text[1][1]-'0';
for(j = 1; j<2; j++){
if(max < (text[i][j]-'0')){
max = text[i][j]-'0';
cout<<max;
}
else
cout <<"xx";
}cout<<endl;
}
return 0;
}