HackerRank Programming - Looping and Skipping - Bash Tutorials Solution - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Monday, October 16, 2017

HackerRank Programming - Looping and Skipping - Bash Tutorials 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,

No comments:

Post a Comment