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 restrict keyword in c?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What are local static variables?
Explain what are run-time errors?
What tq means in chat?
What are the advantages of c language?
Can i use “int” data type to store the value 32768? Why?
How do you define a function?
write a program to print largest number of each row of a 2D array
What are the advantages and disadvantages of c language?
What is meant by preprocessor in c?
Why do we use int main?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
How is a null pointer different from a dangling pointer?
What is the code in while loop that returns the output of given code?