Thread: Arrays using c programming

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Unhappy Arrays using c programming

    does anyone know the answer to this problems, it's giving me a headache>> Given an array of 100 random numbers in the range 1……999, write a function for each of the following processes. In building the array, if the random number is evenly divided by 3 or 7, store it as a negative number.

    a.) Print the array ten values to a line. Make sure that the values are aligned in rows.
    b.) Print the odd values, ten to a line.
    c.) Print the values at the odd numbered index locations, ten to a line.
    d.) Return a count of the number of even values.
    e.) Return the sum of all values in the array.
    f.) Return the location of the smallest value in the array.
    g.) Return the location of the largest value in the array.
    h.) Copy all positive values to a new array. Then use process “a” above to print the new array.
    i.) Copy all negative values to a new array. Then use process “a” above to print the new array.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Yes, first you read this
    Announcements - C Programming

    Then you could read this
    A development process
    and make some kind of attempt at writing just the first step of your assignment.

    If you get stuck, post your code.
    If not, then keep going, one small step at a time.
    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.

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    And you think doing this for no reason is not giving us a headache?
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by claudiu View Post
    And you think doing this for no reason is not giving us a headache?
    We've seen this one before... it's some teacher's screwball idea of a homework assignment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Programming using Arrays.
    By Justin Ling in forum C Programming
    Replies: 21
    Last Post: 04-27-2011, 05:24 PM
  2. Beginner in C programming (arrays)
    By greg677 in forum C Programming
    Replies: 12
    Last Post: 03-24-2010, 01:59 AM
  3. C programming problem - Arrays
    By Eman in forum C Programming
    Replies: 3
    Last Post: 11-22-2009, 06:02 PM
  4. C Programming Help - Using Arrays and Files
    By samdog45 in forum C Programming
    Replies: 1
    Last Post: 03-10-2008, 02:18 AM
  5. 2D arrays programming, please help
    By mfskratch in forum C Programming
    Replies: 4
    Last Post: 11-01-2007, 12:41 PM

Tags for this Thread