FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 81   



Following program shows you how to print average of given 3 numbers.
In this program we get inputs from user and calculate average of given 3 numbers using following formula
Average of given 3 numbers = (input1 + input2 + input3) / 3

 puts "Enter first number:"
 input1 = Integer(gets.chomp)
 puts "Enter second number:"
 input2 = Integer(gets.chomp)
 puts "Enter third number:"
 input3 = Integer(gets.chomp)
 result = (input1 + input2 + input3) / 3
 puts "The average of three numbers: #{result}"

Output:

Enter first number:
20
Enter second number:
10
Enter third number:
30
The average of three numbers: 20



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News