Hello Programmers, In this post, you will know how to solve the Getting started with conditionals HackerRank Solution. This problem is a part of the HackerRank Linux Shell Series.
One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.
Problem
Read in one character from STDIN.
If the character is ‘Y’ or ‘y’ display “YES”.
If the character is ‘N’ or ‘n’ display “NO”.
No other character will be provided as input.
Input Format
One character
Constraints
The character will be from the set {yYnN}.
Output Format
echo YES
or NO
to STDOUT.
Sample Input
y
Sample Output
YES
Getting started with conditionals HackerRank Solutions
#!/bin/bash read word if [[($word == 'y') || ($word == 'Y')]] then echo "YES" elif [[($word == 'n') || ($word == 'N')]] then echo "NO" fi
Note: This problem (Getting started with conditionals) is generated by HackerRank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.