WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Swap two Numbers with and without using third vari

cbtsam
Quote Post


New Member
*

Group: Members
Posts: 2
Member No.: 59691
Joined: 17-September 13


Sponsored Links
Hi Friends, try this c++ swap program in simple n easy way here is the link below
cbtsam.com/cppl1/cbtsam-cppl1-029.php
PMEmail Poster
Top
dila
Quote Post


New Member
*

Group: Members
Posts: 16
Member No.: 823
Joined: 3-December 04


This can be done with regular arithmetic operations too.

Consider this C program:

CODE
#include <stdio.h>

int main() {

 float a = 123.0;
 float b = 456.0;

 printf("a=%.3f b=%.3f\n", a, b);

 a /= b;
 b *= a;
 a /= b;
 a = 1/a;

 printf("a=%.3f b=%.3f\n", a, b);

 return 0;
}


Which prints:

CODE
a=123.000 b=456.000
a=456.000 b=123.000

PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google