Login
|
Signup
langref.org
-
clojure
and
cpp
add..
all
csharp
erlang
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Structure
Loops
Perform an action a fixed number of times (FOR)
Display the string
"Hello"
five times like
"HelloHelloHelloHelloHello"
clojure
(dotimes [_ 5]
(print "Hello"))
(dotimes [_ 5]
(print "Hello"))
cpp
C++/CLI .NET 2.0
for(int i = 0; i < 5; ++i) Console::Write("Hello");
using namespace System;
int main()
{
for(int i = 0; i < 5; ++i) Console::Write("Hello");
}
cpp
C++/CLI .NET 2.0
for(int i = 5; i > 0; --i) Console::Write("Hello");
using namespace System;
int main()
{
for(int i = 5; i > 0; --i) Console::Write("Hello");
}
cpp
dotimes(5, hello);
#include <iostream>
void dotimes(int n, void(*f)()) { if (n != 0) { f(); dotimes(--n, f); } }
void hello() { std::cout << "Hello"; }
int main()
{
dotimes(5, hello);
}
cpp
fill_n(ostream_iterator<string>(cout), 5, "Hello");
#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;
int main()
{
fill_n(ostream_iterator<string>(cout), 5, "Hello");
}
Submit a new solution for
clojure
or
cpp
There are 32 other solutions in
additional
languages (
csharp
,
erlang
,
fantom
,
fsharp
...)