HackerRank Programming – Looping and Skipping – Bash Tutorials Solution

Hackerrank - Bash Tutorials Hackerrank Online Judge Solution

Hackerrank

Problem:

Looping and Skipping in Bash Programming.

Output Format

1
3
5
.
.
.
.
.
99

Solution in Bash Programming Language:

#!/bin/bash
for i in {1..99..2};
do
echo $i;
done


Explanation:
So go to our code. In this line,

for i in {1..99..2};

We take a simple for loop that will go 1 to 99 and that will do two increment.

  1. 1 is first value of i
  2. 99 is the last value of i
  3. 2 is the increments of i

That’s the code. Then just echo or print the i variable. In Bash the variable is printed a dollar sign first, $.
The for loop is completed by done text.

Tags:
Hacker-rank tutorials, Looping and Skipping – Bash Tutorials Solution, Bash Loop, Bash For Loop, Bash Loop System, Hackerrank Online Judge Solution, Hackerrank – Bash Tutorials,

Leave a Reply

Your email address will not be published.