#include <stdio.h>

int main ( int argc, char* argv [ ] )
{
int value1 = 10;
int value2 = 5;
printf ( "\n The sum is :%d", value1 | value2 );

}
This is the answer asked by some one to add two numbers
with out using arithmetic operator?Yes this answer is write
it given out put as 15.But how?????
what is need of following line?
int main ( int argc, char* argv [ ] )
how it work?what is the meaning for this line?
please explain me.Advance thanks

Answer Posted / deepak

binary value of 10 = 1010
binary value of 5 = 0101

so if u do bitwise OR. u will get 1111, which is the binary
value of 15. Note: This will not work for all the case:
For eg, value1 = 5 and value2 = 5 will not give u 10.
Instead the printf will print 5 only.

Is This Answer Correct ?    16 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

693


What is the purpose of clrscr () printf () and getch ()?

689


Write a program to print all permutations of a given string.

768


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

745


Why n++ execute faster than n+1 ?

2080






What is scope rule of function in c?

638


How old is c programming language?

679


pierrot's divisor program using c or c++ code

1838


What is wrong with this program statement? void = 10;

920


What are the advantages of the functions?

717


How do you determine a file’s attributes?

697


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

719


Is c is a procedural language?

711


Explain the difference between #include "..." And #include <...> In c?

708


what will be maximum number of comparisons when number of elements are given?

1528