Home Forums C Programming with out semicolon

Viewing 2 reply threads
  • Author
    Posts
    • #2076
      Priyanka Rajput
      Participant

      Can  u  write  a  ‘C’  program  with out using semicolon ?
      U  should not use any macros…

    • #3356
      Humayan
      Participant

      I guess that depends on your definition of  “a program”. You could just do this:
       

      void main()
      {

      }

       
      This is a do nothing program. The lack of semicolons rules out most expressions and declarations , ect. You could add an empty loop:
       

       while ( 1 )
       {}
       
      or
       while ( 0 )
       {}

       
      Heres a copy of the C grammar that you can check out to maybe find more:
       
      http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

    • #3357
      Humayan
      Participant

      Hes another:
       

      #include 
      void main()
      {
       if ( printf ( "Hello world!n") )
       {}
       if ( printf ( "This is a program with no semicolonsn" ) )
       {}
      }

       
      I think you could build an entire program this way. Have to think about this!

Viewing 2 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.