I understand how sum(10-1) returns 9 - sum(9-1) and so on...but a little confused on the second part, where you mention the return values in line 9....where does the return 2+1 come from and so on?
Type: Posts; User: chakana101
I understand how sum(10-1) returns 9 - sum(9-1) and so on...but a little confused on the second part, where you mention the return values in line 9....where does the return 2+1 come from and so on?
write a recursive method sum that calculates the sum of the integers between 1 and n, using the following recursive definition: The sum of the values from 1 to n is n plus the sum of the values from...
int [] [] mat = new int [3] [4];
for (int row = 0; row < mat.length; row ++ )
{
for ( int col = 0; col < mat[0].length; col++ )
{
if ( row < col )
mat...
public int mystery (int k )
{
if ( k ==1 ) return 0;
else return ( 1 + mystery(k/2) );
}
import java.util.Scanner;
public class Multiples
{
public static void main (String [] args)
{
final int PER_LINE = 5;
int value, limit, mult,...
I see lol glad to know i'm not crazy haha, thanks for the help guys! and it's actually my textbook haha
this is the answer in the back of the book:
6.10:
the code contains an infinite loop. The numbers 10, 11, 12 and so on will be printed until the program is terminated or until the number gets...
in the case of:
int low = 10 , high =0
do
{
So using something else as a similar example:
if (score >= 90) grade = 'A';
if (score >= 80) grade = ' B ';
if (score >= 70 ) grade = 'C';
if (score >= 60 ) grade = 'D';
else grade =...
The way my professor presented the problem in the practice exam, is without the brackets. Because they weren't shown, are they implied to be there? Would it still produce the same output without the...
I have an exam on monday on java programming and i'm still a bit confused about a certain question involving nested if statements, the question is:
What is the output of the following code:
...