Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions c++/countdwon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
#include <stdlib.h>

unsigned short countdown(unsigned short num)
{
if(!num)
{
std::cout << num << std::endl;
return countdown(num--);
}
else
{
std::cerr << "Boooom" << std::endl;
exit(-1);
}
}

int main(int argc, char const *argv[])
{
if(argc == 2)
{
countdown(static_cast<unsigned int>argv[1]);
return EXIT_SUCCESS;
}
else
{
std::cerr << "usage: countdown [NUM]" << std::endl;
return EXIT_FAILURE;
}
}