Introduction
Swapping two numbers means interchanging their values. In this lab, we will learn how to swap two numbers in C language using different methods such as using a temporary variable, addition and subtraction, bitwise operators, multiplication and division.
Note: You need to create the file ~/project/main.c
yourself to practice coding and learn how to compile and run it using gcc.
cd ~/project
## create main.c
touch main.c
## compile main.c
gcc main.c -o main
## run main
./main
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
c(("`C`")) -.-> c/UserInteractionGroup(["`User Interaction`"])
c(("`C`")) -.-> c/BasicsGroup(["`Basics`"])
c(("`C`")) -.-> c/PointersandMemoryGroup(["`Pointers and Memory`"])
c(("`C`")) -.-> c/FunctionsGroup(["`Functions`"])
c/UserInteractionGroup -.-> c/output("`Output`")
c/BasicsGroup -.-> c/comments("`Comments`")
c/BasicsGroup -.-> c/variables("`Variables`")
c/BasicsGroup -.-> c/data_types("`Data Types`")
c/BasicsGroup -.-> c/operators("`Operators`")
c/PointersandMemoryGroup -.-> c/pointers("`Pointers`")
c/FunctionsGroup -.-> c/function_declaration("`Function Declaration`")
subgraph Lab Skills
c/output -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/comments -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/variables -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/data_types -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/operators -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/pointers -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
c/function_declaration -.-> lab-123348{{"`Swapping Two Numbers Program`"}}
end