0% found this document useful (0 votes)
48 views21 pages

Special Session On Pointers

This document summarizes a special session on pointers. It discusses single and two dimensional arrays, and different ways to access elements of two dimensional arrays using pointers like *ptr, **ptr, and *ptr[]. It provides code examples and homework problems related to using pointers with single and two dimensional arrays. The homework involves writing programs to read and print arrays using various pointer methods without declaring arrays, instead using pointers alone or in combination with functions.

Uploaded by

aggarwalmegha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views21 pages

Special Session On Pointers

This document summarizes a special session on pointers. It discusses single and two dimensional arrays, and different ways to access elements of two dimensional arrays using pointers like *ptr, **ptr, and *ptr[]. It provides code examples and homework problems related to using pointers with single and two dimensional arrays. The homework involves writing programs to read and print arrays using various pointer methods without declaring arrays, instead using pointers alone or in combination with functions.

Uploaded by

aggarwalmegha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 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[]

You might also like