23.12.19

Swapping of numbers using call-by-reference program in c

#include<stdio.h>
 

void main()


{


  int a=10,b=50;


  void swap(int *,int *);


  clrscr();


  printf("Before Swapping: %d %d\n",a,b);


  swap(&a,&b);


  printf("After Swapping: %d %d\n",a,b);


}


void swap(int *a,int *b)


{
  int t;

  t=*a;


  *a=*b;


  *b=t;


}



Output :
Before Swapping: 10 50
After Swapping: 50 10

No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...