Umm i just want to ask how to use an array and when to use them. I just cant get what my teacher is telling. Maybe someone can give me a new idea. That's all thanks :)
iamnoangel26 0 Light Poster
Recommended Answers
Jump to PostUmm i just want to ask how to use an array and when to use them. I just cant get what my teacher is telling. Maybe someone can give me a new idea. That's all thanks :)
A good hint might be when you are naming your variables item1, item2, …
Jump to Post>Ok But how can i get the value of the 5th element? does cout<<a[5]; will do?
well,it will ouput the 6'th element, since arrays start on 0.
>And what if i want to output all the elements? do I write cout<<a[0], a[1], a[2]... a[20];
yes, but [20] dont …
Jump to Post#include <iostream> using namespace std; int main() { int array[] = {10,20,30,40,50}; for ( int i = 0; i < 5; ++i ) { cout << "array[" << i << "] = " << array[i] << '\n'; } return 0; } /* my output array[0] = 10 …
All 12 Replies
Dante Shamest 0 Light Poster
Dave Sinkula 2,398 long time no c Team Colleague
bsdpowa 0 Newbie Poster
indianscorpion2 -1 Junior Poster in Training
iamnoangel26 0 Light Poster
zyruz 0 Junior Poster in Training
Dave Sinkula 2,398 long time no c Team Colleague
gazoo 0 Light Poster
Salem 5,265 Posting Sage
gazoo 0 Light Poster
mitrmkar 1,056 Posting Virtuoso
gazoo 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.