BASIC (talaffuzi: Beysik; toʻliq nomi Beginners' All-purpose Symbolic Instruction Code[1] — „boshlovchilar uchun universal ramziy oʻquv kod“) — dasturlashga mutaxassis boʻlmagan foydalanuvchilar (muhandislar, olimlar, talabalar) uchun taxminiy dasturlash tili, 1964-yilda AQShda John G. Kemeny va Thomas E. Kurtz tomonidan ishlab chiqilgan boʻlib, Dartmouth College tomonidan chiqarilgan sanaladi. Asosan shaxsiy EHMlarda foydalaniladi.

SintaksisTahrirlash

Birinchi misol (Microsoft QuickBASICda):

REM QuickBASIC misol

REM Forward declaration - allows the main code to call a
REM    subroutine that is defined later in the source code
DECLARE SUB PrintSomeStars (StarCount!)

REM Main program follows
INPUT "What is your name: ", UserName$
PRINT "Hello "; UserName$
DO
   INPUT "How many stars do you want: ", NumStars
   CALL PrintSomeStars(NumStars)
   DO
      INPUT "Do you want more stars? ", Answer$
   LOOP UNTIL Answer$ <> ""
   Answer$ = LEFT$(Answer$, 1)
LOOP WHILE UCASE$(Answer$) = "Y"
PRINT "Goodbye "; UserName$
END

REM subroutine definition
SUB PrintSomeStars (StarCount)
   REM This procedure uses a local variable called Stars$
   Stars$ = STRING$(StarCount, "*")
   PRINT Stars$
END SUB


Ikkinchi misol (Visual Basic .NETda):

Public Module StarsProgram
   Private Function Ask(prompt As String) As String
      Console.Write(prompt)
      Return Console.ReadLine()
   End Function

   Public Sub Main()
      Dim userName = Ask("What is your name: ")
      Console.WriteLine("Hello {0}", userName)

      Dim answer As String

      Do
         Dim numStars = CInt(Ask("How many stars do you want: "))
         Dim stars As New String("*"c, numStars)
         Console.WriteLine(stars)

         Do
            answer = Ask("Do you want more stars? ")
         Loop Until answer <> ""
      Loop While answer.StartsWith("Y", StringComparison.OrdinalIgnoreCase)

      Console.WriteLine("Goodbye {0}", userName)
   End Sub
End Module

ManbalarTahrirlash

  1. Basic: a manual for BASIC, the elementary algebraic language designed for use with the Dartmouth Time Sharing System, birinchi (inglizcha tilida), Hanover, N.H.: Dartmouth College Computation Center, 1964.. 

HavolalarTahrirlash