Thread: Array Question

  1. #1
    Registered User
    Join Date
    Sep 2010

    Array Question

    I have a math quiz program that you can select a problem type or random, it will provide a summary. I need to add an array that will track all problems as well as answers. My question is should I use a multidimensional array or will a standard array work? Thanks

  2. #2
    Registered User
    Join Date
    May 2010
    How about:

    struct Problems
       std::string problem;
       std::string answer;
    std::vector<Problems> my_problems;

  3. #3
    Registered User
    Join Date
    Sep 2010


    Thanks for the reply, this is for a beginning programming class and I am not looking to get my homework done.

    The answer is probably more advanced than I need. The program gives math problems with randomly generated numbers. I need a display at the end that shows each problem with supplied answer and if correct or not. If the answer is wrong show the correct answer.

    I have the program showing this information when the question is answered a summary with totals and percentage correct.

    I need this information plus a repeat of the problem in a summary.

    My question is would a multidimensional array do this in one array or should I set up an array for each situation (Addition right and wrong ect...).


  4. #4
    Join Date
    Oct 2007
    Inside my computer
    The way I see it is this:
    You have a problem.
    You need to display the problems at the end.

    A problem can modeled as a question, an answer, the correct answer and if it was answered correctly or not.

    So that tells us that our requirements are:
    - We need a model of a problem (a structure or a class).
    - We need to store N problems. This implies an array (or more commonly, a vector).

    Since the problem is one-dimensional, a multi-dimensional array does not make sense.
    I would expand upon what jimblumberg gave you. It should be all you need to crack this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Sep 2010

    Thanks again

    That is the way I was thinking as well thanks for the confirmation..Still need to do some more reading on arrays...

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. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  3. array question?
    By correlcj in forum C++ Programming
    Replies: 1
    Last Post: 11-08-2002, 06:27 PM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM