PROGRAM TO FIND THE SUM OF ARRAY USING RECURSION java
#1

Code:
import java.io.*;
class Arraysum
{
int temp;
      int sum(int a[],int n)
      {
            if(n==1)
                  return a[0];
            else
        {
                  temp =sum(a,n-1);
                   temp=temp+a[n-1];
                   return temp;
        }
       }
}
class Newarray
{
public static void main(String args[])throws IOException
{
DataInputStream dis=new DataInputStream(System.in);
          System.out.println("Enter limit");
         int n=Integer.parseInt(dis.readLine());
         int a[]=new int[10];
         System.out.println("Enter the array");
    

for(int i=0;i<n;i++)
         {  
             a[i]=Integer.parseInt(dis.readLine());
         }
         Arraysum a1=new Arraysum();
         System.out.println("Array sum is"+ a1.sum(a,n));
}
}



OUTPUT
E:\5BCA-B\lijo\java>java Newarray
Enter limit
3
Enter the array
2
3
4
Array sum is 9


Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Tagged Pages: recursive find largest array sum,
Popular Searches: stockmarket retriving using corba program, java program to find out factorial of a number through recursion, where can i find lightsaber in chennai, zero sum, where to find plastic training pants, sum of tachometer ppt, how can i find the college,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
PROGRAM TO FIND THE SUM OF ARRAY USING RECURSION java - by project topics - 06-04-2011, 01:09 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple Key Events Java source code smart paper boy 3 3,589 07-02-2017, 03:41 PM
Last Post: NARESHLAFOOT
  VHDL program for Booth’s Multiplier smart paper boy 2 5,661 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,637 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,856 28-01-2013, 03:21 PM
Last Post: Guest
  Window Events Java source code smart paper boy 1 3,667 02-03-2012, 10:48 AM
Last Post: seminar paper
  Inter net banking java source code smart paper boy 3 5,933 01-03-2012, 11:24 AM
Last Post: seminar paper
  UDP server java source code smart paper boy 1 3,806 05-01-2012, 05:50 PM
Last Post: jeslinapeter
  UDP client Java source code smart paper boy 2 3,665 12-12-2011, 09:56 AM
Last Post: seminar addict
  Text Demo Java source code smart paper boy 0 2,070 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Text Area Demo Java source code smart paper boy 0 2,081 30-08-2011, 12:44 PM
Last Post: smart paper boy

Forum Jump: