Saturday, 14 November 2015

Shell Programming : Program to generate all the combination of 1,2 and 3 using For Loop


Unix Shell Programming tutorialY


You can generate all the combination of any number in Shell Programming .

Here , Program to generate all the combination of 1, 2 and 3 .


Editor : vi

Shell : bash

Run : sh filename


for i in 1 2 3

do

for j in 1 2 3

do

for k in 1 2 3

do

echo $i  $j  $k

done

done

done


OUTPUT :-

1 1 1              
1 1 2
1 1 3
1 2 1
1 2 2 
1 2 3
1 3 1
1 3 2
1 3 3
2 1 1              
2 1 2
2 1 3
2 2 1
2 2 2 
2 2 3
2 3 1
2 3 2
2 3 3
3 1 1              
3 1 2
3 1 3
3 2 1
3 2 2 
3 2 3
3 3 1
3 3 2
3 3 3

Thank You To All My Reader
Aman Kapoor
www.CodeMon5ter.blogspot.in 

No comments:

Post a Comment