From 0842bf577b497e08c07f4b61f39db43726c33109 Mon Sep 17 00:00:00 2001 From: AmitDuseja Date: Mon, 6 Oct 2014 16:28:03 +0530 Subject: [PATCH] Done --- Day1/assignment.rb | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/Day1/assignment.rb b/Day1/assignment.rb index 2d1ce5d..7672b5e 100644 --- a/Day1/assignment.rb +++ b/Day1/assignment.rb @@ -2,24 +2,35 @@ # -------------------------------------------------------------------------- # 1. Write a method to swap two variables. -# def method(a, b) -# Your code here.... +# def swap(a,b) +# c=a +# a=b +# b=c +# puts "A:#{a} B:#{b}" # end - +swap(10,20) # 2. Write any one use case of === operator. -# Your answer here... + +if((1..5)===3) +puts "\n\n 3 is range of 1 to 5" +end +if((1..5)===7) +puts "7 is range of 1 to 5" +else +puts "\n\n 7 is not range of 1 to 5 \n\n" +end # 3. Print array of alphabates using Range operator. -# Your answer here... +('a'..'z').to_a # 4. Print 'Ho! Ho! Ho! Merry Christmas!' using string interpolation and * operator. -# Your answer here... +puts 'Ho!'*3+"Merry Christmas!" @@ -29,4 +40,18 @@ # c. Finally, print result in the form # "Your name is " # "Your age is " -# Your answer here... + +def user() +puts "enter the name" +name=gets +puts "enter the age" +age=gets +puts "hello#{name} your age is #{age}" +end +user() + + + + + +