Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to exchange numbers using pointers

Posted By: Liam Bouchard     Category: C Programming     Views: 6224

Write a program to exchange numbers using pointers.

Code for Program to exchange numbers using pointers in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int x,y;
    x = 100;
    y = 200;
    clrscr();

    printf("Before Exchange : x = %d y = %d\n\n",x,y);
    exchange(&x,&y);
    printf(" After Exchange : x = %d y = %d\n\n",x,y);
    getch();
}
exchange(a,b)
int *a,*b;
{
    int t;
    t = *a;
    *a = *b;
    *b = t;
    return(*a,*b);
}
  
Share: 


Didn't find what you were looking for? Find more on Program to exchange numbers using pointers Or get search suggestion and latest updates.

Liam Bouchard
Liam Bouchard author of Program to exchange numbers using pointers is from Montreal, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!