main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above
Answers were Sorted based on User's Feedback
Answer / govind verma
OK I am done. reason bollean expression in if evaluate in such manner first (1||0) will execute and first expresiion of this boolean expression is one so control will not goes to chek any thing i.e whole expression evaluate as (1||0)as 1(true) now expression becom like dis if(1&&(0||1))
now (0||1) expressiion will evaluate in this expression value of left hand side of || operator is 0(false) so control goes to check further and right hand side it recieve 1 then the value of wholl expression becom 1 thn nw orignal expression looks like if(1&&1)
nw (1&&1) is evalute in this case control check both the value of the operator(&&) is one then this return 1 otherwise return 0 then orignal expression like this if(1)
1 is nonzero value this mean condition is true then code of if block will be execute which is OK I am done.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / naveen kumar
ok i am gone...because in this case the condition if((1||0)
&&(0||1)
always remain true. hence the answer is ok i am done...i.e.
(a
| Is This Answer Correct ? | 1 Yes | 1 No |
Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print
given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
Implement a t9 mobile dictionary. (Give code with explanation )
1 Answers Amazon, Peak6, Yahoo,
main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
void ( * abc( int, void ( *def) () ) ) ();
int a=1; printf("%d %d %d",a++,a++,a); need o/p in 'c' and what explanation too
main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024
how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }