473,748 Members | 9,596 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TWISTER: Add 2 numbers using "SINGLE" variable

Hi,

Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!

Regards
Nirjhar

Nov 23 '06 #1
6 2629
Nirjhar Oberoi wrote:
Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!
int main (void) {
int v;
v = 2 + 3;
return 0;
}

--
Thad
Nov 23 '06 #2
Thad Smith wrote:
Nirjhar Oberoi wrote:
>Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!

int main (void) {
int v;
v = 2 + 3;
return 0;
}
Note that the "Single Variable" [sic] is not required:
int main(void)
{
2 + 3; /* evaluate and discard result */
return 0;
}
Nov 23 '06 #3
Martin Ambuhl <ma*****@earthl ink.netwrites:
Thad Smith wrote:
>Nirjhar Oberoi wrote:
>>Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!
int main (void) {
int v;
v = 2 + 3;
return 0;
}

Note that the "Single Variable" [sic] is not required:
int main(void)
{
2 + 3; /* evaluate and discard result */
return 0;
}
It's required to meet the specification (which I suspect has little to
do with the actual requirement).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 23 '06 #4
Martin Ambuhl wrote:
Thad Smith wrote:
>Nirjhar Oberoi wrote:
>>Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!

int main (void) {
int v;
v = 2 + 3;
return 0;
}

Note that the "Single Variable" [sic] is not required:
int main(void)
{
2 + 3; /* evaluate and discard result */
return 0;
}
While not required to add two numbers, it was stated as a requirement by
the OP, who stipulated a single variable. I debated about whether the
provided code "used" a "Single Variable" to perform the summation (as
opposed to holding the sum). Perhaps I should have written
v = 2;
v += 3; /* v is used to sum two numbers */

--
Thad
Nov 23 '06 #5
Keith Thompson wrote:
Martin Ambuhl <ma*****@earthl ink.netwrites:
>Thad Smith wrote:
>>Nirjhar Oberoi wrote:
Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!
int main (void) {
int v;
v = 2 + 3;
return 0;
}
Note that the "Single Variable" [sic] is not required:
int main(void)
{
2 + 3; /* evaluate and discard result */
return 0;
}

It's required to meet the specification (which I suspect has little to
do with the actual requirement).
Nothing in the specification requires the sum to be stored.
Nov 23 '06 #6
Martin Ambuhl wrote:
Keith Thompson wrote:
>Martin Ambuhl <ma*****@earthl ink.netwrites:
>>>Nirjhar Oberoi wrote:
Can you add two numbers using a Single Variable? :-)
If yes then show me the code!!!
int main(void)
{
2 + 3; /* evaluate and discard result */
return 0;
}

It's required to meet the specification (which I suspect has little to
do with the actual requirement).

Nothing in the specification requires the sum to be stored.
The specification does require a single variable to be used,
however, and your code does not use a single variable.

Nov 23 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1583
by: Phil Powell | last post by:
class DepartmentTree { function &buildTree($id) { static $html; if (!isset($html)) { // DO STUFF HERE TO $html } // DO MORE STUFF if ($condition_is_met) $this->buildTree($newID); $this->html = $html;
3
1604
by: Martin Ink | last post by:
I have a program linked to an .exe and this program is started from an other program. I would like to control the execution of the program so that the program only runs 'single threaded'. I don't want simultaneously session of my program to be run. My program must be an .exe. Is there a way to control this in a simple way ?? Rgds
3
2264
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause resulting into overall time of <60 seconds; The table consists of 950.000 records, and the resultset consists of 205.000 records.
28
4161
by: rajendra.stalekar | last post by:
Hi Folks!!! I have a string let's say "hi" and got to reverse it using just a single variable for swapping, how do I do it? Regards, Rajendra S.
8
2134
by: Michael | last post by:
Hi, I think my problem deals with class casting and inheritance. I want to deal with various Audio Formats, reading into memory for modification, working with it (done by different classes), and writing the result to disk afterwards. Therefore I have created some classes, e.g. WaveFileIO and AiffFileIO and MP3FileIO and AuFileIO for the In/Out operations.
4
6323
by: nirjhar.oberoi | last post by:
Hi, This is my first post on this group! i am beginner lever C programmer. I am trying to add two numbers or multiply them using a single variable! Your are not allowed to use Unions or any other userdefined DS! Inline assembly is accepted! but use only "One Variable" Thanks
2
2174
by: Chris Thomasson | last post by:
I was wondering if the 'SLINK_*' and 'SLIST_*' macros, which implement a simple singly-linked list, will produce _any_ possible undefined behavior: ____________________________ #include <stdio.h> #include <stdlib.h> #include <assert.h>
0
9370
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.