Algorithm


  • Pointer
  • Function

Code Examples

#1 Code Example with C Programming

Code - C Programming



#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main() {
    int num1 = 5, num2 = 10;

    printf("Before swapping: num1 = %d, num2 = %d\n", num1, num2);

    swap(&num1, &num2);

    printf("After swapping: num1 = %d, num2 = %d\n", num1, num2);

    return 0;
}

Copy The Code & Try With Live Editor

Output

x
+
cmd
Before swapping: num1 = 5, num2 = 10
After swapping: num1 = 10, num2 = 5
Advertisements

Demonstration


Next
Appending into a File in C Programming