Question about Microsoft Windows XP Professional

1 Answer

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

Posted by on

1 Answer

  • 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

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));
}

Posted on Mar 06, 2009

Add Your Answer

Uploading: 0%

my-video-file.mp4

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

×

Loading...
Loading...

Related Questions:

1 Answer

Calendar for birthdays


Add the birthday to the contacts in your address book and they are automatically added to your birthdays calendar.

Mar 18, 2013 | Apple MD276LL iPhone 4S 16GB Verizon...

1 Answer

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!

Aug 10, 2011 | Microsoft Windows XP Home Edition

1 Answer

My Internet Explore says it's operated without addon, How can I make it with addon?


Some add-ons are known to be _NOT_ compatible with Internet Explorer 7 or 8 or 9.
So, rather than "crashing" when you start Internet Explorer, it tells you that it has bypassed the "bad" add-on.

If you use the add-on (Yahoo! toolbar? MSN toolbar? Bing toolbar? Google toolbar?),
then you need to download the most-recent version, and install it.

Otherwise, just use I.E. *without* using that add-on.

Mar 18, 2011 | Microsoft Operating Systems

1 Answer

Dvd/cd drive is not shown in my computer


1) Veify its listed in device manager? To check that Right click on My computer and got to manage.There you need to click on device manager.On right side, check whether you are able to see CD/DVD listed. see the pic

2017f49.jpg

If its not listed you need to reconnect the power supply.
If its listed and still not working, check the IDE or Sata cable to connected to it.Refix it.

If you are seeing an yellow mark near CD/DVD drive you can download microsoft fixit from http://www.ziddu.com/download/6528022/MicrosoftFixit50027.msi.html


2)Verify that the CD/DVD drive is detected by the BIOS when the computer starts

You can see how to access bios at http://www.fixya.com/support/r4268275-enter_bios_in_toshiba_laptop

3)Verify that the CD/DVD drive has a drive letter assigned in Disk Manager

423513e.png

a. Click Start, and then click Run. Or click Start Search.
b. Type “diskmgmt.msc” (without the quotes), and then press ENTER
c. Verify that the CD/DVD device is assigned a drive letter (for example, “D:”)
d. If the device does not have a drive letter, then right mouse click on the CD-ROM (highlighted in red above), and select Change Drive Letters and Paths
e. Click Add, click Assign the following drive letter, and then click a drive letter from the list

4)Uninstall & Reinstall the DVD/CD-ROM drive in Device Manager

a. Click Start, and then click Run. Or click Start Search.
b. Type “devmgmt.msc” (without the quotes), and then press ENTER
c. Double click to expand DVD/CD-ROM drives
d. Right-click on the name of your DVD/CD-ROM and click Uninstall
e. Select OK to the Confirm Device Removal (Windows XP) or Confirm Device Uninstall (Windows Vista) dialog
f. Right mouse click your computer name and select Scan for hardware changes
g. Close Device Manager

f: Click OK twice, and then close Disk Management


If all these not solved your issue you can have a look at http://www.fixya.com/support/r4274092-cd_dvd_drive_missing_or_not_recognized

Aug 19, 2010 | Operating Systems

3 Answers

Can't explore pendrive[vista ultimate]


ive got no idea wat a pen drive is but if you open the start menu, right click on computer select properties there should now be a window open, on the left of that window there should be some options one of them is device manager, open it and the device (pendrive) will be there with a yellow symbol next to it click on it and it will give you more info and a repair option, hope this helps if you have more trouble get back to me

Jun 23, 2009 | Microsoft Windows Vista Ultimate Edition

1 Answer

Detects but not actually.......


Are you hooking this device up to a windows computer or a linux computer?

Jan 29, 2009 | Microsoft Windows XP Professional

1 Answer

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.

Jan 15, 2009 | Microsoft Windows XP Home Edition

1 Answer

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.

Jan 06, 2009 | Microsoft Windows Server Standard 2003 for...

1 Answer

Electricity bill coding in java


First think how you would solve this problem yourself on a piece of paper. Then try programming it using the things you learned (if they've given you this assignment without teaching you to multiply, subtract and use if's, drop the course).
Well here is an idea.

Take the total kilowattage and send it to a function. What the function will do is subtract 14KW from the total Kilowattage and add the amount for the first 14KW then subtract 85KW from the total KW and add the amount for the 85KW. But once you subtract the number of KW from the total make sure to check if the total KW isn't negative, if so just break out of the function and return the total due.

Or if you have formula for how much the rate grows over how many miles.

For example lets say the rate grows by $1 every time the KW doubles you could have something like

int rate = 1; //Begining rate
int KW = 14; //First flat rate
int amount; //total amount they have to pay
while(totalKW > 0)
{
totalKW -= KW; //subtract the first rate
if(totalKW <= 0) //check if too much subtracted
break; //if so break
amount += rate; //add the rate to the total

rate += 1; // Add $1 to the rate every time
KW *= 2; // KW is doubled
}

Jan 05, 2009 | Operating Systems

Not finding what you are looking for?
Microsoft Windows XP Professional Logo

Related Topics:

257 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Operating Systems Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Scott Fryer

Level 2 Expert

80 Answers

Carlos L. Burgos
Carlos L. Burgos

Level 2 Expert

508 Answers

Are you a Microsoft Operating System Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...