Question:Swapping program in c using function 

Answer 
#include<stdio.h>

void swap(int *,int *);
int main(){

    int a,b;
   
    printf("Enter any two integers: ");
    scanf("%d%d",&a,&b);

    printf("Before swapping: a = %d, b=%d",a,b);

    swap(&a,&b);

    printf("\nAfter swapping: a = %d, b=%d",a,b);
    return 0;
}

void swap(int *a,int *b){
    int *temp;
    temp = a;
    *a=*b;
    *b=*temp;
}
Sample output: Enter any two integers: 3 6 Before swapping: a = 3, b=6 After swapping: a = 6, b=6 

+ Report
Total Preview: 499
Swapping program in c using function
Copyright © 2025. Powered by Intellect Software Ltd