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

plz send me all data structure related programs

2 Answers  


abcdedcba abc cba ab ba a a

2 Answers  


main() { char a[4]="HELLO"; printf("%s",a); }

3 Answers   CSC,


Sir... please give some important coding questions asked by product companies..

0 Answers  


write a origram swaoing valu without 3rd variable

2 Answers  






main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

2 Answers   CSS, Wipro,


#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }

0 Answers   Student,


how to delete an element in an array

2 Answers   IBM,


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


main() { if (!(1&&0)) { 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

3 Answers   HCL,


main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


Categories