ADVERTISEMENT
ADVERTISEMENT

# Ruby program to calculate the area of Cube

Ruby Example: Write a program to calculate the area of Cube.
Submitted by Nidhi, on November 29, 2021

Problem Solution:

In this program, we will read the side of Cube from the user. Then we will calculate the area of the Cube and print the result.

Program/Source Code:

The source code to calculate the area of Cube is given below. The given program is compiled and executed successfully.

# Ruby program to calculate the
# area of Cube

side=0.0;
area=0.0;

print "Enter side: ";
side = gets.chomp.to_f;

area = 6.0 * side * side;

print "Area of Cube is: ",area;

Output:

Enter side: 2.56
Area of Cube is: 39.3216

Explanation:

In the above program, we created two variables side and area, that are initialized with 0.0. Then we read the side of Cube from the user and calculated the area of Cube using the standard formula. After that, we printed the result.

ADVERTISEMENT
ADVERTISEMENT

Preparation

What's New

ADVERTISEMENT

Top Interview Coding Problems/Challenges!

ADVERTISEMENT

ADVERTISEMENT

Comments and Discussions!

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.