sum of n numbers using arrays

This is a discussion on sum of n numbers using arrays within the C Programming forums, part of the General Programming Boards category; Hello sir, I need a simple program. sum of n numbers using arrays in C...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    6

    sum of n numbers using arrays

    Hello sir,
    I need a simple program.
    sum of n numbers using arrays in C

  2. #2
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    Although I'm rather new to C, this is one method:

    Code:
    int add_array()
    {
    	int array_step = 0;
    	int result = 0;
    	
    	for(array_step = 0, array_step < array_limit, array_step++)
    	{
    		result += your_array[array_step];
    	}
    	
    	return(result);
    }
    If you defined your array as "int your_array[80];" the "array_limit" value is this 80 value.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    6

    Error

    I cant follow your code sir.
    I need full coding for sum of n numbers using arrays

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    If you need it - you should write it.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Make an effort, don't just dump your homework and expect a free handout.
    http://cboard.cprogramming.com/annou...t.php?f=4&a=39

    Feel free to start a new thread with an attempt at solving it yourself. At least make it look like you did more than just walk from your class to the nearest web browser to post your assignment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sum of 2 int arrays
    By maro009 in forum C++ Programming
    Replies: 6
    Last Post: 10-21-2005, 02:07 PM
  2. Replies: 4
    Last Post: 04-19-2005, 08:05 PM
  3. comparing arrays
    By dustyrain84 in forum C Programming
    Replies: 1
    Last Post: 01-21-2004, 04:52 PM
  4. Finding and Printing prime numbers using arrays
    By Sektor in forum C++ Programming
    Replies: 5
    Last Post: 12-11-2003, 07:29 PM
  5. Array's Help
    By bmx4christ in forum C Programming
    Replies: 15
    Last Post: 12-08-2003, 11:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21