473,411 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Swap two int values

i'm new in programing and i do not know, if you can help me with this one...

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values.

Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner .
Feb 16 '08 #1
5 4814
sicarie
4,677 Expert Mod 4TB
Sure, what do you need help with?
Feb 16 '08 #2
bykwzpz
13
Here is a way:

<Code removed my MODERATOR - Please read our Posting Guidelines>
Feb 16 '08 #3
Meetee
931 Expert Mod 512MB
i'm new in programing and i do not know, if you can help me with this one...

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values.

Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner .
It's really very simple. You just need to store one value in temporary variable and swap both. after that value in temp variable can be swaped in another variable!. Just try to write some logic once and the work would be easy :)
Feb 17 '08 #4
i'm new in programing and i do not know, if you can help me with this one...

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values.

Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner .
Hi ,
try this one::
<CODE REMOVED BY MODERATOR - PLEASE READ OUR POSTING GUIDELINES>

and print both variables
Feb 20 '08 #5
i'm new in programing and i do not know, if you can help me with this one...

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values.

Declare any additional variables as necessary, but do not redeclare firstPlaceWinner and secondPlaceWinner .

Sure, that's really simple!
Your code should look something like this.

Seriously? Two freaking people had their code removed, and messages left, and you think for some reason that you are different, or better, or what?

Code freaking removed. Read the Guidelines of this site, this is your one warning, cause apparently you have trouble reading anywya.
Feb 27 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: surrealtrauma | last post by:
if i have circular linked list like: 14->12->10->8->6->4->2->0->// how can i revises it as 0->2->4->6->8->10->12->14->// is there any other method besides swap? Thank you
2
by: ma740988 | last post by:
So I'm reading the C++ coding standards(Shutter & Andrei), more specifically item 56. There's a statement: "Prefer to provide a nonmember swap function in the same namespace as your type when...
7
by: mark | last post by:
Please excuse this blatant attempt at advertising. I hope you find this software both interesting and useful. http://www.caddproductivity.com/dataswap.htm Data Swap The Data Swap program...
28
by: OSHIMA | last post by:
Hi, I found the swap() function without a temporary variable. void swap(int *x, int *y){ *x ^= *y; *y ^= *x; *x ^= *y; } So, I wrote the next code that exchange the double.
12
by: Eugen J. Sobchenko | last post by:
Hi! I'm writing function which swaps two arbitrary elements of double-linked list. References to the next element of list must be unique or NULL (even during swap procedure), the same condition...
14
by: pras.vaidya | last post by:
hi, please help me with this problem : - how to swap two addresses .For eg variable i is located at 2000 and j at 3000 . Now i call swap function . Result should be that i should be now having...
10
by: Atlas | last post by:
To swap to nodes in list, changing pointers is enough. But the stl swap method seems to copy their values, doesn't it?
8
by: meendar | last post by:
This is my program on swap of strings.i just used pointer for swapping the string. can anyone help me why it is not working? #include<iostream.h> #include<string.h> void swap(char *char1,...
10
by: imnilima | last post by:
hey i want to know that how to swap 2 values ,that is one is integer & other is float using pointers in C.
21
by: raylopez99 | last post by:
In the otherwise excellent book C# 3.0 in a Nutshell by Albahari et al. (3rd edition) (highly recommended--it's packed with information, and is a desktop reference book) the following statement is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.