C – Program that attempts to swap the values of two numbers.

Example :-  Program that attempts to swap the values of two numbers.

#include <stdio.h>

void swap( int, int ) ;

void main( )

{

int a, b ;

printf( “Enter two numbers” ) ;

scanf( ” %d %d “, &a, &b ) ;

printf( “a = %d ;  b = %d \n”, a, b ) ;

swap( a, b ) ;

printf( “a = %d ;  b = %d \n”, a, b ) ;

}

void swap( int , int )//This is original form of declarator

int num1, num2 ;

{

int temp ;

temp = num2 ;

num2 = num1 ;

num1 = temp ;

}

 

error: Content is protected !!