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

Why is c known as a mother language?

945


#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); }

952


Explain how do you override a defined macro?

778


What is a scope resolution operator in c?

927


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.

1722






Is it possible to execute code even after the program exits the main() function?

1040


Why c is called procedure oriented language?

772


What is time null in c?

748


What are the disadvantages of external storage class?

779


The file stdio.h, what does it contain?

853


Is fortran still used in 2018?

783


What is size of union in c?

737


Can you pass an entire structure to functions?

878


What is omp_num_threads?

807


What is table lookup in c?

814