What is the output of the program given below

#include<stdio.h>
main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

Answer Posted / sharan

#include<stdio.h>
main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

Here the CATCH is semicolon after for
so maximum positive value for the signed char is 127.
Hence it loops 127 times after that value of i wraps to
negative value that is -128.

Thus it prints -128.

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In C language, a variable name cannot contain?

729


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

598


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1107


What is difference between structure and union?

586


How can I get random integers in a certain range?

604






WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

1579


i got 75% in all semester am i eligible for your company

1725


What does sizeof function do?

602


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1825


When should I declare a function?

611


What is c++ used for today?

649


What is wrong with this statement? Myname = 'robin';

807


List some of the dynamic data structures in C?

774


What are structure types in C?

653


What is the difference between malloc calloc and realloc in c?

638