cplusplus-training/Teil_1/4. Kontrollstrukturen/Uebung 1 - Einmaleins.cpp
2021-10-15 08:36:02 +02:00

56 lines
921 B
C++

#include <iostream>
using namespace std;
void printTableFor();
void printTableWhile();
void printTableDoWhile();
int main()
{
cout << "For Loop\n";
printTableFor();
cout << "While Loop\n";
printTableWhile();
cout << "Do While Loop\n";
printTableDoWhile();
return 0;
}
void printTableFor()
{
for (int i = 1; i < 11; i++)
{
for (int j = 1; j < 11; j++)
cout << (i * j) << "\t";
cout << "\n";
}
}
void printTableWhile()
{
int i = 1;
while (i < 11)
{
int j = 1;
while (j < 11)
{
cout << (i * j) << "\t";
j++;
}
cout << "\n";
i++;
}
}
void printTableDoWhile()
{
int i = 1;
do
{
int j = 1;
do
{
cout << (i * j) << "\t";
j++;
} while (j < 11);
cout << "\n";
i++;
} while (i < 11);
}