Really Basic Question

This is a discussion on Really Basic Question within the C Programming forums, part of the General Programming Boards category; Im trying a bit of C for a friend to try and help them with a problem. Ive set up ...

  1. #1
    Unregistered
    Guest

    Really Basic Question

    Im trying a bit of C for a friend to try and help them with a problem.

    Ive set up an array which gets the user to input values and store them in the array. What I need to do is to add functionality so that if values entered are not in increasing amounts, it outputs an error message.


    /* Input values into the array */
    printf("\nType in %d values for the x coordinates\n", sets);
    for(i=0; i<=sets-1; i++) scanf("%d", &x[i]);


    This receives and stores the values fine. Im guessing i need another for statement somewhere to check that the value entered is greater than the previous one. Please help me!

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    if(array[i] < array[i-1])
    //print your msg

  3. #3
    Unregistered
    Guest
    Thank you! Worked perfectly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic math programming question
    By hebali in forum C Programming
    Replies: 38
    Last Post: 02-25-2008, 04:18 PM
  2. Basic question about GSL ODE func RK4
    By cosmich in forum Game Programming
    Replies: 1
    Last Post: 05-07-2007, 03:27 AM
  3. Basic question about RK4
    By cosmich in forum C++ Programming
    Replies: 0
    Last Post: 05-07-2007, 03:24 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 04:37 PM

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