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
What is the size of structure in c?
What are examples of structures?
What is the difference between int main and void main in c?
Explain what is a pragma?
What is pointers in c with example?
What is indirection in c?
What is f'n in math?
What are # preprocessor operator in c?
what is a function method?give example?
How to get string length of given string in c?
What is the difference between procedural and functional programming?
Does sprintf put null character?
Explain what are the standard predefined macros?
Differentiate between Macro and ordinary definition.
What is the difference between a function and a method in c?