can anyone help me with the output for this 1....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aarti58
    New Member
    • Aug 2007
    • 1

    can anyone help me with the output for this 1....

    [code=c]#include<stdio. h>

    main()
    { enum {red,green,blue };

    clrscr();
    printf("%d %d %d",red,green,b lue);
    return(1);

    }[/code]
    Last edited by sicarie; Aug 29 '07, 04:45 PM. Reason: Code tags, thread title, etc...
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    In the future, please use code tags and a descriptive thread title, as outlined in the Posting Guidelines.

    So why are you unable to compile this code?

    Comment

    • svlsr2000
      Recognized Expert New Member
      • Feb 2007
      • 181

      #3
      Originally posted by aarti58
      [code=c]#include<stdio. h>

      main()
      { enum {red,green,blue };

      clrscr();
      printf("%d %d %d",red,green,b lue);
      return(1);

      }[/code]
      clrscr is declared in conio.h and thats not included. Anyways whats the problem?? clrscr is not standard function, probably thats why you are not able to compile. (If compilations is the problem :^) )

      Comment

      • Ganon11
        Recognized Expert Specialist
        • Oct 2006
        • 3651

        #4
        In addition, you declared your main() function without specifying a return type (which, I believe, will default to void main(), a bad practice in itself), but try to return 1 at the end. Also, returning 1 to main() indicates that there was an error in the program - but your program, if it makes it to the return statement, should have executed perfectly fine.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by Ganon11
          In addition, you declared your main() function without specifying a return type (which, I believe, will default to void main(), a bad practice in itself)
          It's not allowed anymore; in the C89 Standard no return type defaulted to an
          int return type (just as in the good old K&R1 version of C). The C99 Standard
          just doesn't allow this anymore. A lot of current compilers still default a lack
          of a return type to int though for 'convenience' reasons.

          kind regards,

          Jos

          Comment

          Working...