Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 114

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 76

Answer:

main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);

}


Answer:
Behavior is implementation dependent.


Explanation:
The detail if the char is signed/unsigned by default is implementation dependent. If the implementation treats the char to be signed by default the program will print –128 and terminate. On the other hand if it considers char to be unsigned by default, it goes to infinite loop.
Rule:
You can write programs that have implementation dependent behavior. But dont write programs that depend on such behavior.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 114 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: