bashamsc's Avatar, Join Date: May 2007
Go4Expert Member
In C programs we print array elements like

printf("Elements of array a[%d] = %d",i,a[i]);

I want to know how print like above mentioned type in cpp.

Because this type will not work in cpp.

cout<<"a[%d] "<<i<<a[i]; This will not work to print like in c.

Then any other way is there.
Salem's Avatar, Join Date: Nov 2007
Ambitious contributor
Write it out the long way
cout << "a[" << i << "]"