answersLogoWhite

0


Best Answer

I don't specifically know Ruby on Rails, but usually (in most programming languages), to do this task you would define one variable for the sum, and one for a counter. You initialize the sum to zero, and then, in a loop, you (1) increment the counter (most languages specifically have a "for" loop for this), and (2) add the counter to the sum. Here is the pseudocode; it is NOT for a specific programming language, but it gives you the general idea; you should be able to adapt it to most programming languages:

sum = 0

for addend = 1 to 10

{

sum = sum + addend

}

output "Sum = ", sum

Note that you may also need to initialize the variables, depending on the language.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How Write a program to calculate sum of numbers between 0 to 10 in ruby on the rail?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Program in 'c' to find the LCM of any given five numbers?

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.


Write a program in Lex to eliminate white space and collect numbers as a token?

write a lex program to delete space from the program


Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


Write a program to calculate the sum of two numbers in unix?

$vi sum.sh echo "enter the 1st no." read num1 echo "enter the 2nd no." read num2 sum= 'expr $num1 + $num2' echo "sum of the numbers is $sum"


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.

Related questions

How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


Program in 'c' to find the LCM of any given five numbers?

Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.Just write a method or function that calculates the LCM for two numbers at a time. Then calculate the LCM for the first two numbers, get the LCM of the result with the third number, etc.


What are all the whole numbers between 1 to 1000000000?

All of the whole numbers between one and a billion. Honestly, we're not robots here. Write a program and do it yourself, if you really need them.


Write a program to calculate first?

int first= 1;


Write a program in Lex to eliminate white space and collect numbers as a token?

write a lex program to delete space from the program


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


Write a program to print even and odd numbers in between 1 to 10?

for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.


Write a Program in c to find palindrome numbers between any two numbers?

please somebody should help me answer this question..I have a project on it even! It seems almost impossible at the moment.