LearnFrenzy
Sign in Take a free test

Pointers · Exercise 4 of 4

Pointers Pointer Programs

  • 8 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Write each program yourself first, then open the solution. Every solution was compiled and run; the output shown is the real output. Tick "Mark as solved" to track your progress.

Question 1 Easy

Write a function swap() that swaps two integers using pointers, and call it from main().

Question page & discussion
Question 2 Easy

Find the sum and the average of the elements of an integer array by moving a pointer through it (no a[i]).

Question page & discussion
Question 3 Medium

Reverse an integer array in place using two pointers, one from each end.

Question page & discussion
Question 4 Easy

Write my_strlen() that returns the length of a string using a pointer, without calling strlen().

Question page & discussion
Question 5 Medium

Sort an integer array in ascending order with bubble sort, accessing the elements only through pointers.

Question page & discussion
Question 6 Easy

Count the vowels and consonants in a sentence by walking through it with a char pointer.

Question page & discussion
Question 7 Medium

Read n, allocate an array of n integers with malloc(), read the numbers, and print their sum, maximum and average. Free the memory at the end.

Input: 5 then 12 45 7 30 6

Question page & discussion
Question 8 Medium

Write my_strcpy() that copies one string into another using pointers, without calling strcpy().

Question page & discussion
All exercises doneBack to PointersRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Popular