URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       techsuns
  HTML https://techsuns.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: OutPut of a Program
       *****************************************************
       #Post#: 469--------------------------------------------------
       What is the error in this program? 
       By: kranthipls Date: March 15, 2013, 12:19 am
       ---------------------------------------------------------
       It seems there is an error in the below program. Can you help
       find out what it is?
       [code]#include <stdio.h>
       main()
       {
       printf ("Hello World");
       }[/code]
       #Post#: 470--------------------------------------------------
       Re: What is the error in this program? 
       By: dinesh Date: March 15, 2013, 2:04 am
       ---------------------------------------------------------
       Who found that it gave an error? I feel it doesn't give error.
       #Post#: 474--------------------------------------------------
       Re: What is the error in this program? 
       By: kpr29 Date: March 15, 2013, 2:28 am
       ---------------------------------------------------------
       @Kranthi: I feel (I didnt try it out) main statement should have
       return type either void or int something like that........
       kp
       #Post#: 476--------------------------------------------------
       Re: What is the error in this program? 
       By: kpr29 Date: March 15, 2013, 2:38 am
       ---------------------------------------------------------
       @Kranthi: I tried out not giving any error.........
       kp
       #Post#: 477--------------------------------------------------
       Re: What is the error in this program? 
       By: kranthipls Date: March 15, 2013, 11:49 pm
       ---------------------------------------------------------
       I never said it will give an error. All the errors of the
       program need not be communicated to the user. It can be a
       logical error. Logical error has to be found by the user.
       Inorder to save time I am giving the answer in the next reply.
       #Post#: 478--------------------------------------------------
       Re: What is the error in this program? 
       By: kranthipls Date: March 16, 2013, 12:55 am
       ---------------------------------------------------------
       Just like any other function main function is presumed to have a
       return value of int type if no return type is declared for it.
       If you observe the above program there is no return value given.
       When a function is suppose to return int type and doesn't return
       anything a garbage int value is returned. If the return value is
       not used by anyone then there is no problem(in cases of other
       functions.)
       In the case of main it matter. A integer value of 0 is returned
       if the main program is succeeded. Any value other than 0 means a
       failure. This means we are telling the operating system whether
       the program is succeeded or failed.
       So in the above type of program we are communicating a wrong
       information to the operating system.
       For normal use this is fine but this may cause surprising
       results when used with things like software administration
       systems that care about whether programs fail after they have
       invoked them.
       I hope it is explained properly.
       So from now on whenever you write a main function put return 0;
       #Post#: 479--------------------------------------------------
       Re: What is the error in this program? 
       By: kpr29 Date: March 16, 2013, 4:31 am
       ---------------------------------------------------------
       @Kranthi: what ever father says.......
       kp
       *****************************************************