Skip to content

Instantly share code, notes, and snippets.

@sandeepnmenon
Created September 21, 2022 04:37
Show Gist options
  • Save sandeepnmenon/bb35fed22a0697f14ac599464454e060 to your computer and use it in GitHub Desktop.
Save sandeepnmenon/bb35fed22a0697f14ac599464454e060 to your computer and use it in GitHub Desktop.
Duff's device
#include <iostream>
using namespace std;
int main()
{
int count = 7;
switch (
count % 5)
{
case 0:
while (--count > 0) // for (; --count > 0;)
{
cout << count % 5 << endl;
case 1:
cout << count % 5 << endl;
case 2:
cout << count % 5 << endl;
case 3:
cout << count % 5 << endl;
case 4:
cout << count % 5 << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment