How to display Int Arrays using Printf?

Hey,

I currently have Numbers[10]

In which:

1
2
3
Numbers[0]=1;
Numbers[1]=5;
Numbers[2]=3;


I would like to print out all the values present in the Numbers array in a line, so the output display should be: 153

I have got it working with the normal way:

printf("%d %d %d, Numbers[0], Numbers[1], Numbers[3]

I was wondering is there an easy way to display these arrays without having to do %d for each of the array?

Thanks!
Not very fond with Just C but, couldnt you declare an int Result=Numbers[10]
Hey jzp253

Ermm yeah I could but then the only data that will be displayed will be the on in the 10th array of the Numbers variable?

I would like to display all the arrays of the variable in a row
1
2
3
4
for (int i=0; i++; i<10)
{
  std::cout << Numbers[i] << " ";
}
Last edited on
Use a loop?
1
2
3
4
5
6
7
	int ar[ 10 ];

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

	for( int i = 0; i < 10; ++i )
		printf( "%d\n", ar[ i ] );
Topic archived. No new replies allowed.