Swap Two Values

Lab C Beginner 10 points

Read two integers, swap them using a temporary variable and print a=… b=….

Input

Two integers.

Output

One line.

Example

Input

3 9

Output

a=9 b=3
Sample input available Sample output available
Editor
C

Hints

Save a in temp before overwriting it.

Solution explanation

Without the temporary variable the first assignment would lose the original value.

Show solution
#include <stdio.h>

int main() {
    int a, b, temp;
    scanf("%d %d", &a, &b);
    temp = a;
    a = b;
    b = temp;
    printf("a=%d b=%d\n", a, b);
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD