C++ nested loops explained ➿

preview_player
Показать описание
C++ nested loops tutorial example explained

#nested #loop #C++
Рекомендации по теме
Комментарии
Автор

#include <iostream>

int main()
{
int rows;
int columns;
char symbol;

std::cout << "How many rows?: ";
std::cin >> rows;

std::cout << "How many columns?: ";
std::cin >> columns;

std::cout << "Enter a symbol to use: ";
std::cin >> symbol;

for(int i = 1; i <= rows; i++){
for(int j = 1; j <= columns; j++){
std::cout << symbol;
}
std::cout << '\n';
}

return 0;
}

BroCodez
Автор

Hey bro, I know you mentioned that not alot of people watch these C++ series but I just wanted to appreciate you for it


You're the best teacher out there and I'd let you know when I conquer the world.

feggy
Автор

I tried to make the rectangle before looking at your example, but I misinterpreted what you said and made a more difficult version instead :D I feel like I learnt something useful by going through the trial and error


#include <iostream>

int main()
{
int rows;
int columns;
int columncurrent;
int rowcurrent;

std::cout << "Please enter number of rows: ";
std::cin >> rows;

std::cout << "Please enter number of columns: ";
std::cin >> columns;

columncurrent = columns;
rowcurrent = rows;


for(columncurrent; columncurrent > 0; columncurrent--)
{
std::cout << "*";
}
columncurrent = columns;

for(rowcurrent; rowcurrent > 0; rowcurrent--)
{
std::cout << "\n*";
for(columncurrent; columncurrent > 2; columncurrent--)
{
std::cout << "x";
}
columncurrent = columns;
std::cout << "*";
}
std::cout << "\n";
for(columncurrent; columncurrent > 0; columncurrent--)
{
std::cout << "*";
}
return 0;
}

chromakuro
Автор

Bro you helped me a lot. And thanks for making these videos. #respect

dscecseprohitsilrdsem
Автор

Good lesson. Why don't you use namespace std so you don't have to type std every time

hotman
Автор

And again and awesome Video. Defeat the YouTube algorithm.

FrederikWollert
Автор

Great lessons!
i appreciate your hard work very much

artemzakharchuk