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

Comments: 2

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

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

profile
@na3744
23-Feb-2024, 02:52 AM

I bought this course, it worth it!

profile
@mk.info.work
15-Nov-2023, 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

profile
@sciaku1
11-Jan-2024, 03: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 (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?