{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

st08-array - CSC 1111 Introduction to Computing using C...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSC 1111 Introduction to Computing using C++ Arrays (Self-test questions)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Array Initialization int foo[10] = { 10, 9, 8, 7 }; int bar[] = { 1, 2, 3, 4 }; cout << foo [ 0 ] << endl; cout << foo [ 9 ] << endl; cout << bar [ 1 ] << endl; cout << foo [ bar [ 0 ] ] << endl; What's the size of foo[] and bar[] respectively? What's is the output?
Background image of page 2
3 Arrays as parameters string foo[1000]; bar(foo, 1000); Which of these definition of function bar() is syntactically correctly? A. void bar(string x[], int n) { … } B. void bar(string x[100], int n) { … } C. void bar(string x[1000], int m) { … } D. int bar(string x[], int foo) { … }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Arrays as parameters string foo[1000][20]; bar(foo, 1000); Which of these definition of function bar() is syntactically correctly? A. void bar(string x[][], int n) { … } B. void bar(string x[100][20], int n) { … } C. void bar(string x[][1000], int m) { … } D. void bar(string x[1000][], int foo) { … }
Background image of page 4
5 2-D Array Can you declare a 3x10 2-D array in C++ with the following characteristics? 1 st row: Store integer values of type int 2 nd row: Store string objects 3 rd row: Store values of type double
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Arrays as parameters
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}