cplusplus-training/Teil_1/4. Kontrollstrukturen/Lösungen/Loesung Uebung 6 - Continue-Anweisung.cpp
2021-10-15 08:36:02 +02:00

22 lines
507 B
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
using namespace std;
int main()
{
for (int num=0; num<=100; num++)
{
/ * Dies bedeutet, dass wenn der Wert von
        * num nicht durch 2 teilbar ist, dann wird die
        * continue-Anweisung ausgeführt, wodurch die aktuelle Iteration übersprungen
        * wird und und somit die nächste Iteration stattfindet.
        * /
if (num % 2 == 1) // Ist nicht durch die Zahl 2 teilbar
{
continue;
}
cout << num << " ";
}
return 0;
}