Answers for "swap numbers using double pointers"

2

swap two numbers using pointers

#include<stdio.h>

#include<conio.h>

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

void main()

{

int a = 20;

int b = 30;

printf("Before swapped: a = %d and b = %dn",a,b);

swap(&a,&b);

printf("Swapped result: a = %d and b = %dn",a,b);

getch();

}

void swap(int *a, int *b)

{

int temp;

temp = *a;

*a = *b;

*b = temp;

}
Posted by: Guest on March-18-2021

Code answers related to "swap numbers using double pointers"

Browse Popular Code Answers by Language