0

#include <iostream>

using namespace std;

int main() {
int list[12] = {8,1,11,4,2,9,10,5,3,12,6,7};
cout<<list;
return 0;
}

I run the above code and get this:

0x22fef0Press any key to continue . . .

Please help!!!

New with C and new with Dev-C++ which my University wants us to use...

Running from Windows 7
Dev-C++ 4.9.8.3
MinGW compiler

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rahul8590
1

cout
doesnt recognise arrays so you are outputting a pointer what you wanted to do is

#include <iostream>
int main() {
  int list[12] = {8,1,11,4,2,9,10,5,3,12,6,7};
//can go faster but this is easiest to read
for(int j =0 ; j < 12; ++j)
{
 std::cout<<list[j] << " ";
}  
//output a new line
std::cout << std::endl;
return 0;
}
Votes + Comments
Thanks!! Great fast accurate answer!
1

Its an integer array pal .
The right way to print is to put it inside a for/while loop .

for ( int i= 0;i <12 ; i++)
cout<< list[i];

Edited by WaltP: Fixed CODE Tag.

Votes + Comments
:-) thanks learnt something tonight!!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.