tailieunhanh - Lecture Computing for management - Chapter 30

After studying this chapter you will be able to understand: Repetition (looping) control structures; explore how to construct and use count-controlled, sentinel-controlled, flag-controlled, and eof-controlled repetition structures; examine break and continue statements; discover how to form and use nested control structures; | Arrays and Strings Lecture 30 Summary of Previous Lecture In the previous lecture we have covered Functions Prototypes Variable Scope Pointers Introduction to pointers Pointers and function parameters Today’s Topics Arrays Declaration Initialization Input/Output Passing arrays to functions Today’s Topics Character Strings Representation Declaration Index of a char in a string String operations Common mistakes Summary Array An array is a way of lining up objects in rows and columns so they are easier to count or multiply. The rows run from left to right. Array Row: Left to right. This array has 3 rows Array The columns run from top to bottom. This array has four columns. Array Column: Arrays in C Program A group of contiguous memory locations used to store a series of related values. The array name is a pointer to the first element All values have the same type Individual elements of an array are accessed via an integer index: array[index] Referencing Array Elements Element indices start at 0: array[0] is the first element We can reference array elements by using the array’s subscript. The first element has a subscript of 0. The last element in an array of length n has a subscript of n-1. When we write a program, we refer to an individual array element using indexing. To index a subscript, use the array name and the subscript in a pair of square brackets: anyArray[12]; Array Example Declaring an Array To declare an array, we need to specify its data type, the array’s identifier and the size: type arrayName [arraySize]; The arraySize is constant Before using an array we must declare and initialize it! Declaration Examples Initialization at Array Definition Arrays may be initialized with a list of suitable values We can initialize fixed-length array elements when we define an array. If we initialize fewer values than the length of the array, C assigns zeroes to the remaining elements. Array Initialization Examples Arrays and Loops Since we can refer to . | Arrays and Strings Lecture 30 Summary of Previous Lecture In the previous lecture we have covered Functions Prototypes Variable Scope Pointers Introduction to pointers Pointers and function parameters Today’s Topics Arrays Declaration Initialization Input/Output Passing arrays to functions Today’s Topics Character Strings Representation Declaration Index of a char in a string String operations Common mistakes Summary Array An array is a way of lining up objects in rows and columns so they are easier to count or multiply. The rows run from left to right. Array Row: Left to right. This array has 3 rows Array The columns run from top to bottom. This array has four columns. Array Column: Arrays in C Program A group of contiguous memory locations used to store a series of related values. The array name is a pointer to the first element All values have the same type Individual elements of an array are accessed via an integer index: array[index] Referencing Array Elements Element

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.