ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
#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
 Question Submitted By :: Manojkumar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: #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
# 1
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 ?    7 Yes 0 No
Deepak
 
  Re: #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
# 2
hello deepak sir
ur answer is exactly write.Thank you sir.
But i want to know the meaning or this and how it work?
will u please explain me?
thanks.

what is need of following line?
int main ( int argc, char* argv [ ] )
 
Is This Answer Correct ?    0 Yes 0 No
Manojkumar
 
 
 
  Re: #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
# 3
In the printf statement, since the expression uses OR (|), 
answer is correct.. 10 and 5 will be converted to its 
binary equivalent.
10 = 1010
5  = 0101

10 | 5  1010
        0101   gives 1111 which is 15....

Also main function takes only two arguments which 
are "argc" and "argv".. thus the arguments are 
mentioned...even if u just write main() without arguments, 
no problem..
 
Is This Answer Correct ?    2 Yes 0 No
Rahul Pradhan
 
  Re: #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
# 4
ok
thank u sir
 
Is This Answer Correct ?    0 Yes 0 No
Manojkumar
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST? HCL12
HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER  2
What is the difference between null pointer and void pointer CTS3
what r callback function?  1
difference between semaphores and mutex?  1
What is the difference between static and global variables?  1
why we shiuld use main keyword in C  5
What ios diff. Between %e & %f? Honeywell1
What are the preprocessors? HP6
main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain  1
Give me basis knowledge of c , c++...  4
consider the following program sigment int n,sum=1; switch(n) { case 2:sum=sum+2; case 3:sum*=2; break; default:sum=0;} if n=2, what is the value of sum a.0 b.6 c.3 d.none TCS4
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.  4
Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are all defined .Show how a one dimensional array can be implemented by using two stacks. Google3
wats the diference btwen constant pointer and pointer to a constant.pls give examples.  6
write a own function for strstr LG-Soft1
what is dangling pointer? LG-Soft1
What are the average number of comparisons required to sort 3 elements?  2
How to swap two values using a single variable ? condition: Not to use Array and Pointer ?  4
HOW TO HANDLE EXCEPTIONS IN C  5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com