---
title: "Swap the two variable values without taking third variable?"  
description: "Swap the two variable values without taking third variable?"  
author: "Anonymous User"  
published: 2015-09-01  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/22795/swap-the-two-variable-values-without-taking-third-variable  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Swap the two variable values without taking third variable?

int x=10;

int y=5;

x=x+y;

NSLog(@”x==> %d”,x);

y=x-y;

NSLog(@”Y Value==> %d”,y);

x=x-y;

NSLog(@”x Value==> %d”,x);

## Answers

### Answer by Anonymous User

int x=10;

int y=5;

x=x+y;

NSLog(@”x==> %d”,x);

y=x-y;

NSLog(@”Y Value==> %d”,y);

x=x-y;

NSLog(@”x Value==> %d”,x);


---

Original Source: https://www.mindstick.com/interview/22795/swap-the-two-variable-values-without-taking-third-variable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
