#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
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / rahul pradhan
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 ? | 4 Yes | 0 No |
Answer / sivakumar
the argc and argv are mentioned in the main as arguments
those are used for the purpose of command line statements.
if we mentioned the main like (argc,argb[]),then that
program can work as command line program. like dos
functions(type,copy....).
Then at that time argc contains count of parameters and argv
contains list of arguments.
eg:-
show_sum 10 20 30
then argc contain value 3 and argv containe list{10,20,30).
ok.
Is This Answer Correct ? | 3 Yes | 0 No |
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 ? | 1 Yes | 0 No |
Answer / vijay
argc means argument count
argv means argument vector
argc contains the no of arguments and argv[] contains the
argument values
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / valli
why is it taking those two arguments?what is the need of
them?why we are taking integer and character arguments???
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / harish
i think wat rahul explained is true...but one correction to
be made is that main takes three arguments.... i dnt exactly
remember wat its called......
Is This Answer Correct ? | 0 Yes | 3 No |
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What is bubble sort in c?
write a program without using main function?
main() { int l=6; switch(l) { default:l=l+2; case 4:l=4; case 5:l++; break; } printf("%d",l); }
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
0 Answers Sikkim Manipal University,
get any number as input except 1 and the output will be 1.without using operators,expressions,array,structure.don't print 1 in printf statement
Are pointers integers in c?
How to implement a packet in C
What is a symbolic constant?
What is the difference between local variable and global variable in c?
what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā%d\nā,j); }
main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason