Example program oFind sum of squares and sum of cubes of array elements using

Example program ofind sum of squares and sum of cubes

• 17

This preview shows page 6 - 10 out of 17 pages.

Example program: o Find sum of squares and sum of cubes of array elements using pointers. o To copy elements of one array to another using pointer to array. o To find the maximum value out of the array elements. o All the operations possible on arrays.
©LPU CSE101 C Programming (Lec-26)Pointer to group of 1D Arrays 1-D array can be represented in terms of a pointer (array name) and an subscript, 2-D array can also be represented with an equivalent pointer notation. A 2-D array is actually a collection of 1-D arrays. Therefore , we can define a 2-D array as a pointer to a group of contiguous 1-D arrays. 2 D array declaration can be written as data-type (*ptrvar) [expression 2]; rather than data type array[expression 1] [expression 2];
©LPU CSE101 C Programming Eg: a is 2 D array having 10 rows and 20 columns. The item in row 2 and column 5 can be accessed by writing: a [2][5]; or *(*( a +2)+5)
©LPU CSE101 C Programming a is a 2 D array having 10 rows and 20 columns. We can declare x as: int (*a)[20]; Rather than int a[10][20]; In this first declaration, a is defined to be a pointer to a group of contiguous 1 –D 20 element integer arrays. Thus a points to the first 20 element array which is actually the first row i.e row 0 of original 2 D array.

You've reached the end of your free preview.

Want to read all 17 pages?

• Spring '18
• Aman
• Array, Pointer, Function pointer

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern