Pointers as function Arguments || Lesson 62 || C Programming || Learning Monkey ||

preview_player
Показать описание
Pointers as function Arguments

In this class, we will understand the use of Pointers as function Arguments.

We have clearly understood the concepts of pointer variables and the visualization of pointers.
Pointers as function Arguments

So far, we have understood what pointers are, but we haven’t understood the use of pointers.

There are many uses of the pointers in c programming.

One of the important use of pointers is passing them as the function arguments.

We will try to understand the use of passing the arguments of the functions as pointers using the swapping the values of a variable example.

The image below shows the use of arguments as values, NOT as pointers.

The objective above program is to swap the values of i and j.

As we pass the values of arguments as values in the swap function, i and j will get assigned to x and y.

With this assignment, we will lose the connectivity of ‘i’ and j.

The swap function will swap the values of x and y but not the i and j.

With this way of function call, we can not swap the values of i and j.

The image below is the program for swapping the values with arguments as address.

In the above program, the swap function calls have the address of the variables i and j.

In the function definition, the parameters x and y are the pointers to store the ‘address of’ variables i and j.

Now the swap function swaps the values i and j as we pass the references of the variables i and j.

#learningmonkey #cprogrammingforbeginners #placements #gatecse #cprogramming #cprogramminglanguage

Link for playlists:

Рекомендации по теме
Комментарии
Автор

Thank you sir to clear my thoughts on call by refrance

tirthsordhiya
Автор

Hello sir I'm new to your channel and now going learn C from you by the last videos of playlist . Thanks for this valuable knowledge

ayushmansrivastav
Автор

Thanks to you people for helping with our Last minute exam preparations....! Keep going, keep being consistent.. I'm sure you would reach your goal one dayy🤝🤗

sowmiyaravi
Автор

sir pass by value program output(at 11:37) is wrong

sujanreddy
join shbcf.ru