Looping with Numbers in Bash Programming Tutorial Hacker rank - Solution in Bash - 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

Looping with Numbers in Bash Programming Tutorial Hacker rank - Solution in Bash

Hackerrank - Looping with Numbers in Bash Programming Tutorial Hacker rank - Solution in Bash

Problem:
Looping with Numbers in Bash Programming Tutorial Hacker rank.


Output Format
1
2
3
.
.
.
.
.
50 

Solution in Bash Programming Language:



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


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

for i in {1..50..1};

We take a simple for loop that will go 1 to 50  and that will do one increment.


  • 1 is first value of i
  • 50 is the last value of i
  • 1 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, Looping with Numbers in Bash Programming Tutorial Hacker rank - Solution in Bash

No comments:

Post a Comment