Level 1

1.

Take two inputs from user and check whether they are equal or not.

Answer

```
puts "Enter first number"
first = gets.chomp.to_i
puts "Enter second number"
second = gets.chomp.to_i
puts first == second
```

2.

Take 3 inputs from user and check :

all are equal

any of two are equal

( use**&& ****||** )

all are equal

any of two are equal

( use

Answer

```
puts "first number"
first = gets.chomp.to_i
puts "second number"
second = gets.chomp.to_i
puts "third number"
third = gets.chomp.to_i
all = first == second && second == third && third == first
puts "All are equal : #{all}"
any = first == second || second == third || third == first
puts "Any of three are equal: #{any}"
```

3.

Take two number and check whether the sum is greater than 5, less than 5 or equal to 5.

Answer

```
puts "Enter first number"
first = gets.chomp.to_i
puts "Enter second number"
second = gets.chomp.to_i
sum = first+second
puts "Sum is greater than 5 : #{sum>5}"
puts "Sum is equal to 5 : #{sum==5}"
puts "Sum is lesser than 5 : #{sum<5}"
```

4.

Judge the follwing expressions :

!(true && true)

true || false

!(false && true)

false && false

!(true && true)

true || false

!(false && true)

false && false

Answer

```
puts !(true and true)
puts true || true
puts !(false && false)
puts false && false
```

5.

Suppose passing marks of a subject is 35. Take input of marks from user and check whether it is greater than passing marks or not.

Answer

```
pm = 35
marks = gets.chomp.to_i
puts "Marks is greater than passing marks : #{marks>pm}"
```

Recent Posts

7 Critical Tips to Learn Programming Faster

Beginning with ML 2.0: Multivariate Linear Regression

Beginning with Machine Learning: Linear Regression

Scrolling Progress Indicator