Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void gerade(int zahl);
- void ungerade(int zahl);
- int main()
- {
- int zahl, op;
- cout << "Bitte geben Sie eine ganzstellige Zahl ein: ";
- cin >> zahl;
- cout << "geben Sie die 1 fuer gerade und 2 fuer ungerade Zahlen ein: ";
- cin >> op;
- switch (op)
- {
- case 1: gerade(zahl); break;
- case 2: ungerade(zahl); break;
- default: cout<<"Dieser Befehl existiert nicht!!"<<endl;
- }
- system("pause");
- }
- void gerade(int zahl)
- {
- for(int i=0; i<=zahl; i++)
- if (i%2==0)
- cout<<i<<"; ";
- }
- void ungerade(int zahl)
- {
- for(int i=0; i<=zahl; i++)
- if (i%2 == 1)
- cout << i <<"; ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement