Why is this happening?

Posts 1–3 of 3 · Page 1 of 1
Why is this happening?
Im creating a program that given the amount of rows and columns, it a grid that size displaying 0's.

Lets say Row = 2, column = 3 would look like this

000
000

But for some reason It infinatly loops, just keeps on writing 0's to the console. I tried break but it didnt work either.

EDIT : NVM I realized that I messed up the 2nd for.

Close plz

[php]#include <iostream>

int main()
{
int row, column;
std::cout << "Enter amount of rows and columns\n";
std::cin >> row >> column;

for (int i=0; i<row; i++)
{
for (int j=0; i<column; j++)
std::cout << "0";
std::cout << '\n';

}

return 0;
}[/php]

It needs to be a nested For statement also.

EDIT : NVM I realized that I messed up the 2nd for.

Close plz
Code:
#include <iostream>

int main()
{
    int row, column;
    std::cout << "Enter amount of rows and columns\n";
    std::cin >> row >> column;

    for (int i=0; i<row; i++) {

        for (int j=0; i<column; j++){
            std::cout << "0";
          std::cout << '\n';
    }

    }

    return 0;
}

not testing:

Code:
// hilfe.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//
#include "stdafx.h"

#include <iostream>

int main()
{
    int row, column;
    std::cout << "Enter amount of rows and columns\n";
    std::cin >> row;
    std::cout << "Now Enter amount of columns\n";
	std::cin >> column;
    for (int i=0; i<row; i++){

		for (int j=0; j<column; j++){
            std::cout << "0";
    }

       std::cout << '\n';

  }
	system("PAUSE"); 
}
Regards
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us