954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

array does not work?

#include

using namespace std;

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

LeoC++
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

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;
}
tetron
Junior Poster
199 posts since Feb 2010
Reputation Points: 32
Solved Threads: 37
 

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];
rahul8590
Posting Whiz
351 posts since Mar 2009
Reputation Points: 92
Solved Threads: 20
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: