• Active Topics 

Code Syntax Highlighting

This forum is about programming for languages that do not have own forums and anything about programming in a broad spectrum.
Post Reply
User avatar
Admin
Site Admin
Senior Expert Member
Reactions: 56
Posts: 383
Joined: 10 years ago
Has thanked: 38 times
Been thanked: 32 times
Contact:

#1

The code syntax highlighting supports 200+ programming languages in this forum. For the code to look like in real editor, always use the following template:

Code: Select all

 [codebox=language file=codename]Your Code[/codebox] 
where,

language is the name of the programming language, e.g., matlab;

codename, is the file name, including extension, e.g., Hello.m (for MATLAB).

If I re-write the template above, it will look like:

Code: Select all

 [codebox=matlab file=Hello.m]Your Code[/codebox] 
Examples

MATLAB

  1. fprintf ( 1, '\n' );
  2.   fprintf ( 1, 'HELLO:\n' );
  3.   fprintf ( 1, '  MATLAB version\n' );
  4.   fprintf ( 1, '  This is how to say:\n' );
  5.   fprintf ( 1, '\n' );
  6.   fprintf ( 1, '  Hello, world!\n' );


Python

  1. #! /usr/bin/env python
  2. def Hello ( ):
  3.      print ( "Hello, world!" )
  4.      return
  5. if ( __name__ == '__main__' ):
  6.   Hello ( )


C

  1. {
  2.   printf ( "Hello, world!\n" );
  3.   return 0;
  4. }


C++

  1. #include <iostream>
  2. int main() {
  3.   std::cout << "Hello, world!\n"; // Or
  4.  std::cout << "Hello world!" <<std:: endl;
  5.  return 0;
  6. }


FORTRAN77

  1. implicit none
  2. write ( *, '(a)' ) 'Hello, world!'
  3. stop
  4. end


Java

  1. public class HelloWorld {
  2.    public static void main(String[] args) {
  3.      System.out.println("Hello, world");   // Prints "Hello, world"
  4.    }
  5. }


PHP

  1. <html>
  2.  <head>
  3.   <title>PHP Test</title>
  4.  </head>
  5.  <body>
  6.  <?php echo '<p>Hello, world</p>'; ?> 
  7.  </body>
  8. </html>


R

  1. #Suppress quotes in the output
  2. print("Hello World!", quote = FALSE)

@Eli
1
1 Image
TSSFL Stack is dedicated to empowering and accelerating teaching and learning, fostering scientific research, and promoting rapid software development and digital technologies
Post Reply

Return to “Programming (General)”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests