matrix multiplication

I don't know why my program doesn't work or how to fix it so it would work.

my program must calculate the number of connections of a given length which connect two nodes of a diagraph.  My program read the original adjacency matrix from a file, which is this:
0 1 1 0
1 1 1 0
1 0 0 1
0 0 0 0
The program prompts the user for the desired connection length and the names of two nodes.
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <stdlib.h>
int xxx;

void count(int table1[][5], int table2[][5], int table3[][5], int cnt){
      int temp=0;
      int i;
      int j;
      int k;
      cout<<"in count cnt="<<cnt<<endl;
      for (i=0; i<=3; i=i+1){

            for(j=0; j<=3; j=j+1){
                  for (k=0; k<=cnt; k=k+1)

void multiple(int table[][5], int cnt, int size){
      int i;
      int j;
      int k;
      int tempk1[5][5];
      int tempk2[5][5];
      cout<<"in multi cnt="<<cnt<<endl;

      for (i=0; i<cnt; i=i+1){
            for(j=0; j<cnt; j+j+1){


      for (i=1; i<size; i=i+1){
            for (j=1; j<size; j=j+1){
                  count(table, tempk1, tempk2, cnt);

                  for (i=1; i<cnt; i=i+1){
                        cout<<"i'm in the first loop before tempk1";
                        for (j=1; j<cnt; j=j+1){

void main()
      int i, j;
      int node1;
      int node2;
      int length;
      int cnt;
      int size;
      int table[5][5];
      int table3[5][5];
      fstream outFile;"c:/mydocuments/test1.txt",ios::in);
            cout<<"enter length number";
            cout<<"enter node from";
            cout<<"enter node to";
            for (i=0; i<size; i=i+1){
                  for (j=0; j<size; j=j+1){
            for (i=0; i<size; i=i+1){
                  for (j=0; j<size; j=j+1){
            multiple(table, cnt, size);

Who is Participating?
andromeda120198Connect With a Mentor Commented:
You have k and  table3 as unrefernced local variable.modify your program by referring to these local variables.Let me know what else problems you have ?
What problems are you having?
>> modify your program by referring to these local variables
tulchirxAuthor Commented:
thanks anyway, but my program works now alright
All Courses

From novice to tech pro — start learning today.