What is the output of the program given below

main()

{

signed char i=0;

for(;i>=0;i++) ;

printf("%d\n",i);

}



What is the output of the program given below main() { signed ..

Answer / susie

Answer :

-128

Explanation

Notice the semicolon at the end of the for loop. THe initial
value of the i is set to 0. The inner loop executes to
increment the value from 0 to 127 (the positive range of
char) and then it rotates to the negative value of -128. The
condition in the for loop fails and so comes out of the for
loop. It prints the current value of i that is -128.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Code Interview Questions

String reverse with time complexity of n/2 with out using temporary variable.

10 Answers   NetApp, Symantec,


Write a function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


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

5 Answers   HCL,


main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }

1 Answers   Zoho,


main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }

1 Answers  






main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


void main() { int i=i++,j=j++,k=k++; printf(ā€œ%d%d%dā€,i,j,k); }

1 Answers  


writte a c-programm to display smill paces

2 Answers  


What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


Categories