← Back to Lua Course | Chapter 1: Introduction | Lesson 3 of 7

आपका पहला Program

एक Lua program बस instructions की एक text file है जो print, calculate और decide करती है।

आपका पहला Program

एक Lua script एक plain text file है, आमतौर पर .lua से खत्म होती है, ऊपर से नीचे तक चलती है। print function इसके arguments screen पर एक newline के साथ लिखता है। Strings quotes के बीच लिखी जाती हैं और .. operator से जोड़ी जाती हैं।

Note: Scripts को .lua extension से save करें ताकि editors इन्हें recognise करें।

उदाहरण: Your first program

lua
local name = "World"
print("Hello, " .. name .. "!")
print("2 + 3 =", 2 + 3)

-- Output:
-- Hello, World!
-- 2 + 3 =	5
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. कई arguments वाली एक call में print के बाद parentheses भूल जाना
  2. strings जोड़ने के लिए .. की बजाय + इस्तेमाल करना
  3. opening और closing quotes mismatch करना
चैप्टर सारांश
  • एक script ऊपर से नीचे तक चलती है
  • print एक newline add करता है
  • Strings single या double quotes इस्तेमाल करती हैं
  • .. strings जोड़ता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.