Let's Practice Pointers

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 89:- Let's Practice Pointers

Sure! Let's practice some pointer exercises in C. I'll provide you with a few tasks to work on. Remember to understand the concepts and double-check your code for correctness and memory safety.

Exercise 1: Write a C function that swaps the values of two integers using pointers. The function should have the following prototype:

cCopy code

void swap(int *a, int *b);

Exercise 2: Write a C function that takes an array of integers and its size as input and returns the sum and average of the elements in the array using pointers. The function should have the following prototype:

cCopy code

void sum_and_average(int arr[], int size, int *sum, float *average);

Exercise 3: Write a C function that reverses an array of integers in-place using pointers. The function should have the following prototype:

cCopy code

void reverse_array(int arr[], int size);

Exercise 4: Write a C function that takes two strings as input and checks if the second string is a substring of the first string using pointers. The function should return 1 if the substring is found; otherwise, it should return 0. The function should have the following prototype:

cCopy code

int is_substring(const char *str, const char *substring);

Exercise 5: Write a C function that takes an array of integers and its size as input and dynamically allocates memory for a new array that contains only the even elements from the original array. The function should return a pointer to the new array. Remember to free the dynamically allocated memory when it's no longer needed.

cCopy code

int* get_even_elements(const int arr[], int size);

Feel free to try solving these exercises. If you get stuck or need help, I'm here to assist you! Happy coding!

12. Basics Maths and Pointers

2 Comments

@mk.info.work
mk.info.work Feb 17, 2024 at 10:20 PM

SCIAKU Team please upload 1st video of TREE please please please, please

@na3744
na3744 Feb 23, 2024 at 2:52 AM

I bought this course, it worth it!

@mk.info.work
mk.info.work Nov 15, 2023 at 10:25 PM

Hi i want to buy this course but you dont have master card payment method please let me know how i can buy it

@sciaku1
sciaku1 Jan 11, 2024 at 3:23 PM

Dear mk.info.work, Now we have all types of payment options. If you need to purchase just checkout our official website

Frequently Asked Questions About Sciaku Courses & Services

Quick answers to common questions about our courses, quizzes, and learning platform

Didn't find what you're looking for?

help_center Contact Support