23.12.19

Swapping of Numbers by call-by-value program in c

#include<stdio.h>

void main()

{
int a=100,b=200;

void swap(int,int);

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

swap(a,b);

}

void swap(int m,int n)
{
int temp ;

temp=m;
m=n;
n=temp;

printf("After swap a=%d,b=%d",m,n);
}



OUTPUT:

Before swap a=100 and b=200
After swap a=200 and b=100

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...