Home / CSE MCQs / Ruby Programming MCQs :: Discussion

Discussion :: Ruby Programming MCQs

  1. What is the output of the given code?

    string = gets.chomp
    case string
    when string = "a"
    print "alphabet a"
    when string = "b"
    print "alphabet b"
    when string = "c"
    print "alphabet c"
    else 
        print "some other alphabet"
    end
  2. A.
    alphabet a
    B.
    b alphabet b
    C.
    alphabet c
    D.
    Syntax error

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    After taking input from the user will check which string is entered and goes to particular case statement. Output: b alphabet b


Be The First To Comment