Thread: HELP!! i though addition problems were over after 3rd grade!

  1. #1
    Registered User
    Join Date
    Nov 2001

    Question HELP!! i though addition problems were over after 3rd grade!

    I have been assigned to write a program that randomly generates two arrays of 25 int values each, and adds them element by element.

    array1--->5 6 4 2 8 0 2 4 7 5 4.......
    array2--->2 2 7 4 8 1 8 2 9 3 6.......

    array3--->7 9 1 7 6 2 0 7 6 9 0

    Ive already designed and tested the code to add, but when it comes time for the user to enter the answer, the assignment specifically asks to enter it as a sting, so the user can enter a continuous # instead of one by one.

    the way ive gone about this, is by declaring a string:

    char array4[26]; (i added one number for the null character)

    and this is where im can i get the user to enter a continuous number and have the compiler check to see if the user is correct?? ive been trying to solve this every way for the last few days and nothing!!!
    Any help is greatly appreciated!

  2. #2


    I assume you mean that you wish to check the string to make sure every char is a digit, if so use isdigit().

    for (int i = 0; int i < 26; i++) {
        if (!isdigit(array4[i])) { // NOT A DIGIT }
        else { // IS A DIGIT }
    That should work, unless I'm too tired and am being an idiot again. =b

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 12:33 PM
  2. problems addign 3rd party source to VS
    By m37h0d in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 07:03 AM
  3. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  4. problems with structures and linked lists
    By jwillisoa in forum C Programming
    Replies: 7
    Last Post: 07-01-2007, 05:23 PM
  5. test scores
    By ucme_me in forum C Programming
    Replies: 4
    Last Post: 11-14-2001, 01:48 PM