2016-04-15

Learn Computer Languages from BASIC,C++, JAVA, C# to PHP at once

Computer programming languages from BASIC,C++, JAVA, C#  to PHP seem different, but actually they can do the same task. We can study them all together under some basic topics.

The first lesson of coding to understand assignment like a=a+1. This is not an equation. It simply means compute a+1 and put the result back to a.

Here we list some statements of assignment in five different programming languages: BASIC,C++, JAVA, C# and PHP.



' Value Assignment
iA = 1*2+3/4-5
iB = 1*(2+3)/4-5
iC =iA  Mod  2

' Print  iA,iB,iC

' String Assignment
sS="abc"

' String Catenation
sS=sS+"<>"
sS=sS+"def"

' Print  sS



BASIC:
        ' *******************************************
        '  Assignment Statement BASIC
        ' *******************************************
        Sub AssignmentStatement()
            Dim iA as Integer
            Dim iB as Integer
            Dim iC as Integer
            Dim sS as String
            ' Value Assignment
            iA = 1*2+3/4-5
            iB = 1*(2+3)/4-5
            iC =iA  Mod  2
            Debug.Print " ";iA;
            Debug.Print " ";iB;
            Debug.Print " ";iC;
            Debug.Print
            ' String Assignment
            sS="abc"
            ' String Catenation
            sS=sS+"<>"
            sS=sS+"def"
            Debug.Print " ";"sS=";
            Debug.Print " ";sS;
            Debug.Print
        End Sub

C++:
        /* ******************************************* */
        /* Assignment Statement  C++                                    */
        /* ******************************************* */
        void AssignmentStatement() {
            int iA;
            int iB;
            int iC;
            char* sS;
            /* Value Assignment */
            iA = 1*2+3/4-5;
            iB = 1*(2+3)/4-5;
            iC =iA % 2;
            printf(" %d" , iA);
            printf(" %d" , iB);
            printf(" %d" , iC);
            printf("\n" );
            /* char* Assignment */
            vstrcpy((char**)&sS, "abc");
            /* char* Catenation */
            vstrcat((char**)&sS, "<>");
            vstrcat((char**)&sS, "def");
            printf(" %s" , "sS=");
            printf(" %s" , sS);
            printf("\n" );
            vfree((char*)sS);
        }

JAVA:
        // *******************************************
        // Assignment Statement JAVA
        // *******************************************
        public void AssignmentStatement()  {
            int iA;
            int iB;
            int iC;
            String sS = null;
            // Value Assignment
            iA = 1*2+3/4-5;
            iB = 1*(2+3)/4-5;
            iC =iA % 2;
            System.out.print(" "+iA );
            System.out.print(" "+iB );
            System.out.print(" "+iC );
            System.out.println("");
            // String Assignment
            sS="abc";
            // String Catenation
            sS=sS+"<>";
            sS=sS+"def";
            System.out.print(" "+"sS=" );
            System.out.print(" "+sS );
            System.out.println("");
        }

C#:
        /* ******************************************* */
        /* Assignment Statement C#                                        */
        /* ******************************************* */
        public void AssignmentStatement()  {
            int iA;
            int iB;
            int iC;
            String sS = null;
            /* Value Assignment */
            iA = 1*2+3/4-5;
            iB = 1*(2+3)/4-5;
            iC =iA % 2;
            Console.Write(" "+iA);
            Console.Write(" "+iB);
            Console.Write(" "+iC);
            Console.WriteLine("");
            /* String Assignment */
            sS="abc";
            /* String Catenation */
            sS=sS+"<>";
            sS=sS+"def";
            Console.Write(" "+"sS=");
            Console.Write(" "+sS);
            Console.WriteLine("");
        }

PHP:
        /* ******************************************* */
        /* Assignment Statement  PHP                                    */
        /* ******************************************* */
        function AssignmentStatement()  {
            /* Value Assignment */
            $iA = 1*2+3/4-5;
            $iB = 1*(2+3)/4-5;
            $iC =$iA % 2;
            echo " ".$iA;
            echo " ".$iB;
            echo " ".$iC;
            echo "";
            /* String Assignment */
            $sS="abc";
            /* String Catenation */
            $sS.="<>";
            $sS.="def";
            echo " "."sS=";
            echo " ".$sS;
            echo "";
        }

No comments:

Post a Comment