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
Why is c known as a mother language?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
Explain how do you override a defined macro?
What is a scope resolution operator in c?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Is it possible to execute code even after the program exits the main() function?
Why c is called procedure oriented language?
What is time null in c?
What are the disadvantages of external storage class?
The file stdio.h, what does it contain?
Is fortran still used in 2018?
What is size of union in c?
Can you pass an entire structure to functions?
What is omp_num_threads?
What is table lookup in c?