Swap number function call by reference

#include <stdio.h> void swapnum ( int *var1, int *var2 ) { int tempnum ; tempnum = *var1 ; *var1 = *var2 ; *var2 = tempnum ; } int main( ) { int num1 = 35, num2 = 45 ; printf("Before swapping:"); printf("\nnum1 value is %d", num1); printf("\nnum2 value is %d", num2); /*calling swap function*/ swapnum( &num1, &num2 ); printf("\nAfter swapping:"); printf("\nnum1 value is %d", num1); printf("\nnum2 value is %d", num2); return 0;

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.