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: find people by address, find the area of different shapes in java programming, array of students with marks list java program, c program to find identifier, moving banner program in java, c program to find largest of n numbers, how to find the criiminals identification for vb project,

[-]
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,583 07-02-2017, 03:41 PM
Last Post: NARESHLAFOOT
  VHDL program for Booth’s Multiplier smart paper boy 2 5,656 20-04-2013, 11:59 AM
Last Post: T
  Program in “LEX” to count number of vowels and consonants seminar class 2 9,630 22-03-2013, 10:20 AM
Last Post: computer topic
  Program in “LEX” to count number of Identifiers and Keywords seminar class 1 4,851 28-01-2013, 03:21 PM
Last Post: Guest
  Window Events Java source code smart paper boy 1 3,660 02-03-2012, 10:48 AM
Last Post: seminar paper
  Inter net banking java source code smart paper boy 3 5,928 01-03-2012, 11:24 AM
Last Post: seminar paper
  UDP server java source code smart paper boy 1 3,802 05-01-2012, 05:50 PM
Last Post: jeslinapeter
  UDP client Java source code smart paper boy 2 3,660 12-12-2011, 09:56 AM
Last Post: seminar addict
  Text Demo Java source code smart paper boy 0 2,069 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Text Area Demo Java source code smart paper boy 0 2,076 30-08-2011, 12:44 PM
Last Post: smart paper boy

Forum Jump: