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

why nlogn is the lower limit of any sort algorithm?

0 Answers  


write the function. if all the character in string B appear in string A, return true, otherwise return false.

11 Answers   Google,


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])

1 Answers  






Find the largest number in a binary tree

7 Answers   Infosys,


main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

1 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


main() { int i = 3; for (;i++=0;) printf(ā€œ%dā€,i); }

1 Answers   CSC,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\nā€", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

3 Answers   HCL,


int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could anyone explain this to me.

2 Answers   Bosch, eInfochips, HCL, IHCL,


Categories