Microsoft Windows XP Professional Logo

Related Topics:

Posted on Mar 05, 2009
Answered by a Fixya Expert

Trustworthy Expert Solutions

At Fixya.com, our trusted experts are meticulously vetted and possess extensive experience in their respective fields. Backed by a community of knowledgeable professionals, our platform ensures that the solutions provided are thoroughly researched and validated.

View Our Top Experts

How to add two no in c without any operator (even assignment operator)?

1 Answer

Anonymous

Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that got 5 achievements.

Sniper:

An expert who has posted more than 50 answers, of which 90% or more were rated as helpful.

Governor:

An expert whose answer got voted for 20 times.

  • Expert 50 Answers
  • Posted on Mar 06, 2009
Anonymous
Expert
Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that got 5 achievements.

Sniper:

An expert who has posted more than 50 answers, of which 90% or more were rated as helpful.

Governor:

An expert whose answer got voted for 20 times.

Joined: Nov 24, 2008
Answers
50
Questions
1
Helped
23395
Points
154

This code doesn't include any overflow error checking mechanism. It is not much difficult to implement one however.
#include <stdio.h>
int main(){
unsigned num1,num2,result=0,i=0,temp=0;
printf("Enter the two numbers:\n");
scanf("%d",&num1);
scanf("%d",&num2);
for (i= ~0; i; i>>= 1){ //ensure that the body of the loop is executed 8*sizeof(unsigned) times where 8 is the number of bits in a byte. The number of bits in a byte can be more than 8 on some machines.
temp<<= 1;
temp|= (num1^num2^result)&1;
result= ((num1|num2)&result|num1&num2)&1;//to understand this line and the one above take a look at the full adder circuit above
//here temp is the equivalent of S1 in the full adder circuit above and result is the equivalent of C1
num1>>= 1;
num2>>= 1;
}
//the bit order in temp would be in the reverse order. the following code snippet reverses the order
for (i= ~0, result= ~i; i; i>>= 1){
result<<= 1;
result|= temp&1;
temp>>= 1;
}
printf("Sum: %d",result);
return 0;
}

Here is another elegant solution that uses recursion
#include <stdio.h>
int add(int a, int b){
if (!a) return b;
else
return add((a & b) << 1, a ^ b);
}
int main(){
printf("Enter the two numbers: \n");
int a,b;
scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

By Default Panasonic - 824 CO1, CO2, CO3 are working. now i add 2nd card How can i assign CO4, CO5, CO6?

Lines are assigned in program 400. Normally, they are assigned by default so someone had to work very hard to unnasign them even though you didn't have the hardware.
2helpful
1answer

Can't get windows xp home edition to recognize wireless printer, even after assigning printer TCP/IP address. Windows 7 computer prints to it, but the Windows XP computer can't even find the...

Hi!

You din't wrote what's the model of your printer, but I think we can find a solution:
1. Try to ping the IP adress you assigned to the printer. If that works, please download the latest drivers or installation software from the manufacturer of your printer (or second option use the installation disk that came with your printer). If it does not reply to ping, be sure the IP adress you assigned to the printer is in same range as the IP adresses on your network.
2. It is possible that the installation software itself manage to find the printer on the network, and that means the problem is solved
3. If not, install the printer as it is local attached (e.g USB or LPT port)
4. After installing as local printer, please go to printer proprieties, go to port, choose add a new port, choose standard tcp/ip port and write for the port the IP adress you assigned to the printer.
5. Apply changes and ...that's it.

Please let me know if it helped,

Good luck!
1helpful
1answer

How can i assign a ip address to canon ir3025 in windows

open printer properties of some printer and select PORT, go on ADD PORT, and create IP port, then assign it to Canon Ir 3025. Be sure that the same IP, Subnet and gateway are on PC and copier. Under cmd run ping comand, eg. ping 192.168.1.100, and if you have replay without 100 % loss it would be OK.
7helpful
2answers

I have the AT&T Model 854 4-line phone. When the phone is plugged in the phone starts toning and won't stop.

Thats because its looking for the intercom number to be assigned. as soon as you assign one in programming it will stop.
0helpful
1answer

Cannot put music on my pny micro sd card using realplayer

should mount the memory card as a drive letter in my computer if not then right click on my computer and go to manage and then disk management and assign it a drive letter ( right click and assign drive letter ) if thats possible then just drag and drop the music into the relevant folder(s)
0helpful
1answer

Limited or no connectivity. No assign network Add. to comp.

Have you checked the cable?
Try this with a new cable installed:
Go to Start menu > Run > type "cmd" (without the quotes) and hit Enter or click OK.
In the black DOS-window type "ipconfig/release" (without the quotes) and press Enter.
Type "ipconfig/renew" (without the quotes)
and press Enter.
When the DOS windows displays an IP-number (e.g 192.168.1.2), close the DOS-window and try to connect.
Alternatively right click the network-connection icon down on the far right beside the clock and choose "Repair"
Good luck!
;)
0helpful
1answer

Xp home & wireless printer won't install

Add the printer in a TCP/IP port and assign it that IP address. /Add Printer/local connection then set it to TCP/IP port and the printers ip address.
1helpful
1answer

Dhcp in server 2003 in domain not working

Windows 2003 server supports DHCP. If you don't see in Administrative tool DHCP maybe the DHCP role is not enabled. You can add this role in "Manage your server". You don't need to reinstall win 2003 server.
Another way to access DHCP management tool is: in command prompt type mmc and then File> "Add remove snap-in" then "Add" and select DHCP.
0helpful
1answer

Samsung d900i

Create contact (Menu 2.3)
Use this menu to add a new contact to Phonebook.
Storing a number in the phone’s memory
1. Select Phone.
2. Change the settings or enter information about the
contact:
First name/Last name: assign a name.
Mobile/Home/Office/Fax/Other: add a
number in any category.
You can change the number type, or set the
number as the default for the contact by
pressing <Options> and selecting Change
type
or Mark as default number.
Email: assign an e-mail address.


Graphic ID: assign a caller ID image to alert
you to a call from the person.


Ringtone: assign a ringtone to alert you to a
call from the person.
Group: assign the number to a caller group.
Birthday: enter the person’s birthday.
Notes: add a memo about the person.
3. Press <Save> or [ ] to save the contact.
Storing a number on the SIM card
1. Select SIM.
2. Select New or Update.
3. Enter information about the contact:
Name: assign a name.
Phone number: add a number.
Location: assign a location number.
4. Press <Save> or [ ] to save the contact.
Not finding what you are looking for?

274 views

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

k24674

Level 3 Expert

8093 Answers

Brad Brown

Level 3 Expert

19187 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...