another array question

This is a discussion on another array question within the C++ Programming forums, part of the General Programming Boards category; ok actually its 2 questions... first.. how do i get a program to fill an array with a certain number ...

  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
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    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, 06: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, 05:27 PM

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