बेसिक

विकिपीडिया, मुक्‍त ज्ञानकोशातून

संगणकाची एक भाषा संगणकाकडून कोणतेही काम करून घेण्यासाठी , प्रथम सूचनांची एक यादी प्रोग्रॅमिङ् लँग्वेजचा उपयोग करून तयार केली जाते. ह्या यादीला 'प्रोग्रॅम' म्हटले जाते. संगणक ह्या यादीनुसार ठरावीक क्रमाने, ठरावीक क्रिया करून इच्छित काम पार पाडतो.

प्रोग्रॅमिंग लँग्वेजेसचे अनेक वेगवेगळ्या दृष्टीने वर्गिकरण केले जाते .

कार्यनिष्ठ भाषा (Procedural languages) उदा. सी (C), कोबॉल (COBOL), फोर्ट्रान, बेसिक, एपीएल

उदाहरणे[संपादन]

Unstructured BASIC[संपादन]

10 INPUT "What is your name: ", U$
20 PRINT "Hello "; U$
30 INPUT "How many stars do you want: ", N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars? ", A$
100 IF LEN(A$) = 0 THEN GOTO 90
110 A$ = LEFT$(A$, 1)
120 IF A$ = "Y" OR A$ = "y" THEN 30
130 PRINT "Goodbye ";U$
140 END

Structured BASIC[संपादन]

INPUT "What is your name: ", UserName$
PRINT "Hello "; UserName$
DO
  INPUT "How many stars do you want: ", NumStars
  Stars$ = STRING$(NumStars, "*") 
  PRINT Stars$
  DO
    INPUT "Do you want more stars? ", Answer$
  LOOP UNTIL Answer$ <> ""
  Answer$ = LEFT$(Answer$, 1)
LOOP WHILE UCASE$(Answer$) = "Y"
PRINT "Goodbye "; UserName$

BASIC with object-oriented features[संपादन]

 
Class stars
    Sub Main()
        Dim UserName, Answer, stars As String ' UserName$, Answer$, stars$ may be used as well.
        Dim NumStars, I As Integer
        Console.Write("What is your name: ")
        UserName = Console.ReadLine()
        Console.WriteLine("Hello {0}", UserName)
        Do
            Console.Write("How many stars do you want: ")
            NumStars = CInt(Console.ReadLine())
            stars = New String("*", NumStars)
            Console.WriteLine(stars)
            Do
                Console.Write("Do you want more stars? ")
                Answer = Console.ReadLine()
            Loop Until Answer <> ""
            Answer = Answer.Substring(0, 1)
        Loop While Answer.ToUpper() = "Y"
        Console.WriteLine("Goodbye {0}", UserName)
    End Sub
End Class