Thread: another array question

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    77

    Talking another array question

    ok actually its 2 questions...

    first..
    how do i get a program to fill an array with a certain number imputed by the user?

    second..
    how can i make a program divide the numbers in 1 array with the numbers in another?

    thanks for the help
    Hooked On Phonics Didn't Work For Me!

  2. #2
    1)

    -Get input from the user any way you like. getch() or whatever.
    -Then just use a for loop.
    Code:
    for (int i = 0; i < MAX_ARRAY_ELEMENTS; i ++)
       array[i] = input_from_user;
    2)

    Simular to the first.

    Code:
    for (int i = 0; i < MAX_ARRAY_ELEMENTS; i ++)
    {
       if (array2[i] != 0) //we dont want division by zero
          Result[i] = array1[i] / array2[i];
       else
          Result[i] = 0;
    }
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 07:07 PM
  2. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. array question?
    By correlcj in forum C++ Programming
    Replies: 1
    Last Post: 11-08-2002, 06:27 PM