Add Two Numbers Without Using the Addition Operator
Answer / Deenendra Pal Singh
In C, you can add two numbers without using the addition operator by bitwise XOR (^) and AND (&) operations. Here's an example: `((a ^ b) >> 31) ^ b`. This works because XOR gives a 1 if at least one of the corresponding bits in the operands is 1, and shifts it to the most significant bit. Then by XORing it again with the original number (b), the carry will be eliminated.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is define c?
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;
Define C in your own Language.
Where static variables are stored in memory in c?
main is a predefined or user define function if user defined why? if predefined whay?
Can you please explain the difference between malloc() and calloc() function?
Given a piece of code int x[10]; int *ab; ab=x; To access the 6th element of the array which of the following is incorrect? (A) *(x+5) (B) x[5] (C) ab[5] (D) *(*ab+5} .
what does ‘segmentation violation’ mean?
Write code for initializing one dimentional and two dimentional array in a C Program?
5 Answers Deshaw, Edutech, GMD,
Explain what is the difference between functions getch() and getche()?
Write a program to find the smallest and largest element in a given array in c language