C Pass Pointers as the Function Arguments

Pass pointers as the function arguments in c; Through this tutorial, we will learn how to pass pointers as the function arguments in c.

C Pass Pointers as the Function Arguments

/* Pass Pointers to Functions in C Example  */

#include<stdio.h>

void Swap(int *x, int *y)
{
    int Temp;
    Temp = *x;
    *x = *y;
    *y = Temp;
}

int main()
{
    int a, b;

    printf ("Please Enter 2 Integer Values :  ");
    scanf("%d %d", &a, &b);

    printf("\nBefore Swapping  A = %d and B = %d", a, b);

    Swap(&a, &b);

    printf(" \nAfter Swapping   A = %d and B = %d \n", a, b);
}

The output of the above c program; is as follows:

Please Enter 2 Integer Values :  1 2
Before Swapping  A = 1 and B = 2
After Swapping   A = 2 and B = 1 

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *