PROGRAM TO SWAP TWO NUMBERS USING POINTERS | CODE WITH SHARAD

PROGRAM TO SWAP TWO NUMBERS USING POINTERS

Written by Sharad Raj on 13th of March, 2018

C LANGUAGE PROGRAMS   POINTER PROGRAMS

PROGRAM CODE

#include<stdio.h>

void s(int,int);

void main()

{

int x,y;

scanf("%d%d",&x,&y);

s(&x,&y);

printf("Value of x and y after swapping is %d and %d ",x,y);

getch();

}

s(int *p,int *q)

{

int temp; temp=*p; *p=*q; *q=temp;

}


Comments


Contact