C programming
C programming

Swapping two number using Function (Call By Reference)

Swapping two number using Function (Call By Reference)

 

C Programming

Swapping two number using Function (Call By Reference)

 

Question:

Write a program to swap two number using Function (Call by Reference)

Solution:

#include<stdio.h>
void swap(int *,int *);
int main (){
    int a,b;
    printf(“Enter the first number\n”);
    scanf(“%d”,&a);
    printf(“Enter the second number\n”);
    scanf(“%d”,&b);
    printf(“Number \n a=%d \t b=%d \n”,a,b);
    swap(&a,&b);
    printf(“Number \n a=%d \t b=%d \n”,a,b);
    return 0;
}
void swap(int *x,int *y){
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
    printf(“Reversed number \n a=%d \t b=%d \n”,*x,*y);
}

Topics Covered :

  • swap 2 numbers using function
  • swap two numbers
  • swapping numbers
  • call by reference method
  • call by value
  • function
  • c programming
  • swap

 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

🧑‍💻🧑‍💻 Social Media Links of Tech DCode :

👉🏻 YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
👉🏻 Instagram : https://www.instagram.com/thetechdcode/
👉🏻 Facebook Page : https://www.facebook.com/thetechdcode
👉🏻 Twitter : https://twitter.com/thetechdcode
👉🏻 Telegram Channel : https://t.me/thetechdcode
👉🏻 Tech DCode Linktree : https://linktr.ee/thetechdcode
👉🏻 My Personal Handles : https://linktr.ee/virtualshivamin

🧑‍💻🧑‍💻 Social Media Links of SHIVAM SINGH (OWNER) :

👉🏻 Instagram : https://www.instagram.com/virtualshivamin/
👉🏻 Facebook Page : https://www.facebook.com/virtualshivamin/
👉🏻 Twitter : https://twitter.com/virtualshivamin/
👉🏻 Personal Linktree : https://linktr.ee/virtualshivamin 

 

 

Leave a Reply

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