mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-19 22:49:55 +00:00
56 lines
921 B
C++
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);
|
|
} |