Вы находитесь на странице: 1из 21

Special Session on Pointers

Arrays

Contents

Single dimensional Two dimensional

Pointers
meaning of *ptr, **ptr and *ptr[] Accessing single dimensional array using *ptr Accessing two dimensional array using *ptr Accessing two dimensional array using **ptr Accessing two dimensional array using *ptr[]

Pointers and strings Pointer and structure

WAP to read N values for single dimensional array and print the same. (Refer pointer_1.c)

Arrays

Points to be noted
array index starts with 0 array elements are stored in contiguous memory locations scanf requires address

WAP to read MxN values for two dimensional array and print the same. (Refer pointer_2.c)

WAP to read N values for single dimensional array and print the same.(Refer pointer_3.c)
use two functions read_array write_array

WAP to read N values for single dimensional array and print the same.(Refer pointer_4.c)
use two functions read_array write_array

Declare array local to main function How to pass array to function? Pass array address to function and receive it using pointer

Home work
WAP to read MxN values for two dimensional array and print the same. (Refer pointer_2.c). Use read_array and write_array functions and declare array global variable WAP to read MXN values for two dimensional array and print the same. (Refer pointer_2.c). Use read_array and write_array functions and declare array local variable in main function

WAP to read N values and store them in N contiguous memory locations and print the same.(Refer pointer_5.c)
use only pointers

How assign starting address of contiguous memory location to a pointer?

Solution

WAP to read N values and store them in N contiguous memory locations and print the same.
use only pointers use functions read_array() and write_array()

WAP to read MxN values for two dimensional array and print the same. (Refer pointer_6.c) do not use array use *ptr Note:
Two dimensional array is stored in contiguous memory locations Elements are stored row wise use the following formula to access mth row nth column
*(ptr+ rowsize *m + n)

WAP to read MxN values for two dimensional array and print the same. (Refer pointer_7.c) do not use array use **ptr

Homework
WAP to read MxN values for two dimensional array and print the same. do not use array use *ptr[]

Вам также может понравиться