Click here to Skip to main content
15,919,879 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
How do you write arrays with integers and doubles and put them in for loops?
Posted
Comments
Sergey Alexandrovich Kryukov 30-Nov-13 19:06pm    
The question makes no sense at all. Write where? What do you want to achieve, exactly, and what's the problem?
—SA
fkassaie 2-Dec-13 0:57am    
do you want both of them(doubles and integers) together in one array?

1 solution

Try:
C++
int data[10];
int index;
for (index = 0; index < 10; index++)
    {
    data[index] = index * 2;
    }
Or
C++
double data[10];
int index;
for (index = 0; index < 10; index++)
    {
    data[index] = index * 2.5;
    }
 
Share this answer
 
Comments
Stefan_Lang 2-Dec-13 9:00am    
Or:
double source[10];
double destination[10];
int index;
for (index = 0; index < 10; ++index)
destination[index] = source[index];

;-)
P.S.: ok, you might want to initialize the source array first - but hey, who said it should be sensible?
OriginalGriff 2-Dec-13 9:29am    
:laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900