8 Codes to Find Versions



The following is a collection of Codes used to Determine the Language or Compiler Version being used.


   *The following Featured Codes were Created by John Wells



PHP Version


<?php
echo "PHP Version ".phpversion()."<br>";
?>

Click here to run this code



Java Version


public class Program {
  public static void main(String[] args) {
    System.out.format("Java Version = '%s'",
        System.getProperty("java.version"));
  }
}

Click here to see this code run



Swift Version


#if swift(>=4.2)
 print("Running Swift 4.2 or later")
#else
#if swift(>=4.1)
 print("Running Swift 4.1")
#else
#if swift(>=4.0)
 print("Running Swift 4.0")
#else
 print("Running Swift earlier than 4.0")
#endif
#endif
#endif

Click here to run this code



Ruby Version


print "ruby #{ RUBY_VERSION }p#{ RUBY_PATCHLEVEL }"

Click here to see this code run



Python Version


import sys
print(sys.version)

Click here to run this code



C# Runtime Version


import sys
print(sys.version)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace SoloLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Runtime Version: {0}", Environment.Version.ToString());
    

Click here to see this code run




C++ GNU Version


#include <iostream>
using namespace std;

int main() {
  cout << "GNU C++ Version " << __GNUC__ << '.' <<
      __GNUC_MINOR__ << '.' << __GNUC_PATCHLEVEL__ <<
      endl;
  return 0;
}
    

Click here to run this code




C GNU Version


#include <stdio.h>

int main() {
  printf("GNU C Version %d.%d.%d", __GNUC__,
      __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
  return 0;
}

Click here to see this code run



More Free Code Examples:


Hello World in 10 Programming Languages







Comments

Popular posts from this blog