C Programming Exercise - Program to Swap 2 Numbers Without Using Temporary, Third Variable

C Programming Exercise - Program to Swap 2 Numbers Without Using Temporary, Third Variable

LearningLad

9 лет назад

81,697 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Md Anwar Hossain Anu
Md Anwar Hossain Anu - 04.11.2023 19:17

int a,b;
printf(" Enter Two values : ");
scanf(" %d %d ", &a,&b);
printf(" Before swap a = %d and b = %d ", a,b );

a=a+b;
b=a-b;
a=a-b;
printf(" After swap a = %d and b = %d ", a,b );

cant run

Ответить
Huehue
Huehue - 20.07.2023 05:32

THanks

Ответить
Vasco da Gama
Vasco da Gama - 12.06.2023 15:30

yayyyyyyy

Ответить
padma K
padma K - 14.03.2023 03:21

Thanks a lot sir ❤

Ответить
udita bhaumik
udita bhaumik - 04.03.2023 10:04

You don't have to fake an American accent

Ответить
Naman Sharma
Naman Sharma - 02.03.2023 23:55

a=ya 😂😂

Ответить
Yash K
Yash K - 31.12.2021 18:26

Can i try same in python yes or no

Ответить
Lakki Reddy Naga Shasidhar Reddy
Lakki Reddy Naga Shasidhar Reddy - 28.02.2021 11:42

Which software is this

Ответить
Dennis Joshua
Dennis Joshua - 16.11.2020 13:23

Thanks bro

Ответить
mohit rajpurohit
mohit rajpurohit - 14.08.2020 15:29

Nice vidio 😘😘😘😘

Ответить
Priyanka singhaniya
Priyanka singhaniya - 18.11.2019 07:13

Sir 2135 out 5132 hota h to program kyasay bnayegay

Ответить
Software Engineering
Software Engineering - 05.02.2019 16:52

Geo :)

Ответить
Desterius Anami
Desterius Anami - 29.10.2017 14:28

hello, may you please help me write a C program in functions
1. by refrence
2. By value

Ответить
Informative Content
Informative Content - 23.10.2017 22:40

wth is yay it's a

Ответить
ahammad jassim
ahammad jassim - 18.04.2017 15:38

why don't we swap a,b to b,a in the printf statements?

Ответить
Diogo Xavier
Diogo Xavier - 13.06.2016 19:36

Here's a better, faster, way:
a=a+b-(b=a)
works with numbers as long as they are the same type, and with characters.

Ответить
Phan Sào Nam
Phan Sào Nam - 10.04.2015 00:01

This method works only if 2 number a + b is not overflow.
It's better to use the XOR method.
A ^= B
B ^= A
A ^= B
or combine them A ^= B ^= A ^= B

Ответить
Ketan Parmar
Ketan Parmar - 09.04.2015 09:53

which terminal is this?? it is not devcpp which u used in previous videos.

Ответить
Mitchell Taylor
Mitchell Taylor - 11.10.2014 14:41

Here's an alternative method using xor: a ^= b ^= a ^= b;

Ответить