001-005-015

Swapping Variable Values

Medium

Problem Description

Swapping Variable Values

Learning Objective: Understand how to swap values between two variables

Overview

Declare integer variables a with 10 and b with 20, swap their values using a temporary variable, and output both values.

Specifications

  • Initialize variable a with 10 and b with 20
  • Swap values of a and b using a temporary variable temp
  • Output the swapped values

Output Format

a: 20
b: 10

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?