Thread: Arrays and loops

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    367

    Arrays and loops

    Will this code create an array like this: 1,2,3,4,5,6,7,8,9,10?

    int i_array[10];

    for(int i=0; i<=10; i++)
    {
    i_array[i] = i;
    }
    I couldn't be bothered to search for something similar or to read the FAQ.
    Last edited by Zewu; 05-25-2002 at 09:51 AM.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Are you a troll?

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    for(int i=0; i<=10; i++)
    Don't do that. You declare 10 cells but loop thu 11!

    Try this:

    for(int i=0; i < 10; i++)
    i_array[i] = i+1;


    ...but yeah, you were close...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    The good thing about questions is that they are never stupid. It's people that...
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using arrays and loops for math
    By LLINE in forum C++ Programming
    Replies: 3
    Last Post: 06-09-2008, 04:09 AM
  2. Too many loops D:
    By F5 Tornado in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2007, 01:18 AM
  3. while loops with arrays
    By volk in forum C Programming
    Replies: 2
    Last Post: 02-04-2003, 07:22 PM
  4. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM
  5. loops and arrays
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-03-2001, 03:12 PM