SlideShare a Scribd company logo
1 of 14
Download to read offline
PROGRAMMING
IN
LUA
(if –else/if-elseif/while loop/nested
while loop)
INDEX
1 Program to accept the number from user and check it’s a palindrome or not
2 Program to accept the number from user and check it’s an ARMSTRONG or not.
3 Program to accept the decimal number from user and display its binary number
4 Program to accept the binary number from user and display its decimal number
5 program to print series 0,3,8,15,24,35,48,63,80,99....N
6
program to print output as given
1
12
123
1234
12345
7
program to print output as given
1
121
12321
1234321
123454321
8 Program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55
9 Program to create Simple Calculator(+,-,*,/)
10 Program to Check the year is a Leap Year or not
11 Program to Compute Sum of Series1+ x2
/3! + x3
/5! + x4
/3! + x5
/4! + .. + xn
/2n-1!
--[[Program to accept the number from user and check it’s a palindrome or not.]]--
no=0
tmp=0
oldval=0
print("Enter the number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp*10+x
no=math.floor(no/10)
end
if(tmp == oldval)
then
io.write("It’s a palindrome")
else
io.write("It’s a not palindrome")
end
-------------------output------------------
Enter the number
1221
It’s a palindrome
--[[Program to accept the number from user and check its a ARMSTRONG or not.]]--
no=0
tmp=0
oldval=0
print("Enter the number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp+x^3
no=math.floor(no/10)
end
if(tmp == oldval)
then
io.write("Its a armstrong")
else
io.write("Its a not a armstrong")
end
-------------------output------------------
Enter the number
153
It’s an Armstrong
--[[Program to accept the decimal number from user and display its binary number]]--
no=0
tmp=0
oldval=0
print("Enter the decimal number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%2)
tmp=tmp*10+x
no=math.floor(no/2)
end
no=tmp
tmp=0
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp*10+x
no=math.floor(no/10)
end
print("binary of "..oldval.."= "..tmp)
--------------------output--------------------------
Enter the decimal number
23
binary of 23= 10111
--[[Program to accept the binary number from user and display its decimal number]]--
no=0
tmp=0
oldval=0
a=0
print("Enter the binary number")
no=tonumber(io.read())
oldval=no
while(no ~= 0)
do
x=math.floor(no%10)
tmp=tmp+(x*2^a)
no=math.floor(no/10)
a=a+1
end
print("Decimal of "..oldval.."= "..tmp)
------------------------output------------------
Enter the binary number
10111
Decimal of 10111= 23
--[[program to print series 0,3,8,15,24,35,48,63,80,99....N]]--
N=0
tmp=0
a=0
a1=0
x=0
print("Enter the value of N")
N=tonumber(io.read())
while(x<=N)
do
tmp=x+a
io.write(tmp..",")
x=x+1
a1=a1+2
a=a+a1
end
--[[program to print Pentagonal number Series 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176]]—
N=0
tmp=0
print("Enter the value of N")
N=tonumber(io.read())
x=0
while(x<=N)
do
tmp=(3*x*x-x)/2
io.write(tmp..",")
x=x+1
end
------------------output--------------------
Enter the value of N
10
0,1,5,12,22,35,51,70,92,117,145
--[[program to print output as given
1
12
123
1234
12345
]]--
x=1
k=4
while(x<=5)
do
a=1
while(a<=k)
do
io.write(" ")
a=a+1
end
k=k-1
y=1
while(y<=x)
do
io.write(y)
y=y+1
end
print()
x=x+1
end
--[[program to print output as given
1
121
12321
1234321
123454321
]]--
x=1
k=4
while(x<=5)
do
a=1
while(a<=k)
do
io.write(" ")
a=a+1
end
k=k-1
y=1
while(y<=x)
do
io.write(y)
y=y+1
end
z=x-1
while(z>=1)
do
io.write(z)
z=z-1
end
print()
x=x+1
end
--[[program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55]]--
x=1
insum=0
outsum=0
while(x<=5)
do
y=1
insum=0
io.write("(")
while(y<=x)
do
insum=insum+x
io.write(y.."+")
y=y+1
end
io.write("b)+")
outsum=outsum+insum
x=x+1
end
print("b="..outsum)
--[[ Program to create Simple Calculator(+,-,*,/) ]]--
ch=' '
op1=0
op2=0
print("Enter the op1 and op2")
op1=tonumber(io.read())
op2=tonumber(io.read())
print("Enter the operator(+,-,/,*)")
ch=io.read()
if(ch=="+")
then
print(op1.."+"..op2.."="..(op1+op2))
elseif(ch=="-")
then
print(op1.."-"..op2.."="..(op1-op2))
elseif(ch=="/")
then
print(op1.."/"..op2.."="..(op1/op2))
elseif(ch=="*")
then
print(op1.."*"..op2.."="..(op1*op2))
else
print("invalid operator")
end
----------------------output----------------------
Enter the op1 and op2
10
20
Enter the operator(+,-,/,*)
+
10+20=30
--[[Program to Check Leap Year]]--
yy=0
print("Enter the year")
yy=tonumber(io.read())
if(yy%100 == 0 or yy%4==0 or yy%400==0)
then
print("its a leap year")
else
print("its not a leap year")
end
---------------------output----------------------
Enter the year
1988
its a leap year
--[[Program to Compute Sum of Series 1 + x2/3! + x3/5! + x4/3! + x5/4! + .. + xn/2n-1!]]--
sum=1.00
a=2
fact=1
y=0
print("Enter the value of x,N")
x=tonumber(io.read())
N=tonumber(io.read())
while(a<=N)
do
tmp=x^a
fact=1
y=2*a-1
while(y>=1)
do
fact=fact*y
y=y-1
end
sum = sum +tmp/fact
a=a+1
end
print("sum="..sum)
-------------------output-------------------------
Enter the value of x,N 2 10
sum=1.7365977440172

More Related Content

What's hot (20)

week-11x
week-11xweek-11x
week-11x
 
C programs
C programsC programs
C programs
 
Applied numerical methods lec2
Applied numerical methods lec2Applied numerical methods lec2
Applied numerical methods lec2
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Operating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - EngineeringOperating Systems lab Programs - Fourth Semester - Engineering
Operating Systems lab Programs - Fourth Semester - Engineering
 
Public class arithmetic operatordemo
Public class arithmetic operatordemoPublic class arithmetic operatordemo
Public class arithmetic operatordemo
 
Dsp lab task 2
Dsp lab task 2Dsp lab task 2
Dsp lab task 2
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Intro to matlab
Intro to matlabIntro to matlab
Intro to matlab
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Csci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingCsci101 lect06 advanced_looping
Csci101 lect06 advanced_looping
 
week-4x
week-4xweek-4x
week-4x
 
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
.Cpp
.Cpp.Cpp
.Cpp
 

Similar to PROGRAMMING IN LUA (IF-ELSE/IF-ELSEIF/WHILE LOOP/NESTED WHILE LOOP

Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdfYashMirge2
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptMahyuddin8
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersSheila Sinclair
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]vikram mahendra
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdfpaijitk
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical pavitrakumar18
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]vikram mahendra
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programsvineetdhand2004
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdfssuser476810
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsProf. Dr. K. Adisesha
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfFashionColZone
 

Similar to PROGRAMMING IN LUA (IF-ELSE/IF-ELSEIF/WHILE LOOP/NESTED WHILE LOOP (20)

Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
 
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Talk Code
Talk CodeTalk Code
Talk Code
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
Useful c programs
Useful c programsUseful c programs
Useful c programs
 
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdfHello, I need some assistance in writing a java program THAT MUST US.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdf
 
Zone IDA Proc
Zone IDA ProcZone IDA Proc
Zone IDA Proc
 

More from vikram mahendra

Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemvikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shopvikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMvikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Pythonvikram mahendra
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONvikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONvikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1vikram mahendra
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2vikram mahendra
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONvikram mahendra
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONvikram mahendra
 

More from vikram mahendra (20)

Communication skill
Communication skillCommunication skill
Communication skill
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
 

Recently uploaded

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 

PROGRAMMING IN LUA (IF-ELSE/IF-ELSEIF/WHILE LOOP/NESTED WHILE LOOP

  • 2. INDEX 1 Program to accept the number from user and check it’s a palindrome or not 2 Program to accept the number from user and check it’s an ARMSTRONG or not. 3 Program to accept the decimal number from user and display its binary number 4 Program to accept the binary number from user and display its decimal number 5 program to print series 0,3,8,15,24,35,48,63,80,99....N 6 program to print output as given 1 12 123 1234 12345 7 program to print output as given 1 121 12321 1234321 123454321 8 Program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55 9 Program to create Simple Calculator(+,-,*,/) 10 Program to Check the year is a Leap Year or not 11 Program to Compute Sum of Series1+ x2 /3! + x3 /5! + x4 /3! + x5 /4! + .. + xn /2n-1!
  • 3. --[[Program to accept the number from user and check it’s a palindrome or not.]]-- no=0 tmp=0 oldval=0 print("Enter the number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp*10+x no=math.floor(no/10) end if(tmp == oldval) then io.write("It’s a palindrome") else io.write("It’s a not palindrome") end -------------------output------------------ Enter the number 1221 It’s a palindrome
  • 4. --[[Program to accept the number from user and check its a ARMSTRONG or not.]]-- no=0 tmp=0 oldval=0 print("Enter the number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp+x^3 no=math.floor(no/10) end if(tmp == oldval) then io.write("Its a armstrong") else io.write("Its a not a armstrong") end -------------------output------------------ Enter the number 153 It’s an Armstrong
  • 5. --[[Program to accept the decimal number from user and display its binary number]]-- no=0 tmp=0 oldval=0 print("Enter the decimal number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%2) tmp=tmp*10+x no=math.floor(no/2) end no=tmp tmp=0 while(no ~= 0) do x=math.floor(no%10) tmp=tmp*10+x no=math.floor(no/10) end print("binary of "..oldval.."= "..tmp) --------------------output-------------------------- Enter the decimal number 23 binary of 23= 10111
  • 6. --[[Program to accept the binary number from user and display its decimal number]]-- no=0 tmp=0 oldval=0 a=0 print("Enter the binary number") no=tonumber(io.read()) oldval=no while(no ~= 0) do x=math.floor(no%10) tmp=tmp+(x*2^a) no=math.floor(no/10) a=a+1 end print("Decimal of "..oldval.."= "..tmp) ------------------------output------------------ Enter the binary number 10111 Decimal of 10111= 23
  • 7. --[[program to print series 0,3,8,15,24,35,48,63,80,99....N]]-- N=0 tmp=0 a=0 a1=0 x=0 print("Enter the value of N") N=tonumber(io.read()) while(x<=N) do tmp=x+a io.write(tmp..",") x=x+1 a1=a1+2 a=a+a1 end
  • 8. --[[program to print Pentagonal number Series 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176]]— N=0 tmp=0 print("Enter the value of N") N=tonumber(io.read()) x=0 while(x<=N) do tmp=(3*x*x-x)/2 io.write(tmp..",") x=x+1 end ------------------output-------------------- Enter the value of N 10 0,1,5,12,22,35,51,70,92,117,145
  • 9. --[[program to print output as given 1 12 123 1234 12345 ]]-- x=1 k=4 while(x<=5) do a=1 while(a<=k) do io.write(" ") a=a+1 end k=k-1 y=1 while(y<=x) do io.write(y) y=y+1 end print() x=x+1 end
  • 10. --[[program to print output as given 1 121 12321 1234321 123454321 ]]-- x=1 k=4 while(x<=5) do a=1 while(a<=k) do io.write(" ") a=a+1 end k=k-1 y=1 while(y<=x) do io.write(y) y=y+1 end z=x-1 while(z>=1) do io.write(z) z=z-1 end print() x=x+1 end
  • 11. --[[program to print output as given (1)+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+5)=55]]-- x=1 insum=0 outsum=0 while(x<=5) do y=1 insum=0 io.write("(") while(y<=x) do insum=insum+x io.write(y.."+") y=y+1 end io.write("b)+") outsum=outsum+insum x=x+1 end print("b="..outsum)
  • 12. --[[ Program to create Simple Calculator(+,-,*,/) ]]-- ch=' ' op1=0 op2=0 print("Enter the op1 and op2") op1=tonumber(io.read()) op2=tonumber(io.read()) print("Enter the operator(+,-,/,*)") ch=io.read() if(ch=="+") then print(op1.."+"..op2.."="..(op1+op2)) elseif(ch=="-") then print(op1.."-"..op2.."="..(op1-op2)) elseif(ch=="/") then print(op1.."/"..op2.."="..(op1/op2)) elseif(ch=="*") then print(op1.."*"..op2.."="..(op1*op2)) else print("invalid operator") end ----------------------output---------------------- Enter the op1 and op2 10 20 Enter the operator(+,-,/,*) + 10+20=30
  • 13. --[[Program to Check Leap Year]]-- yy=0 print("Enter the year") yy=tonumber(io.read()) if(yy%100 == 0 or yy%4==0 or yy%400==0) then print("its a leap year") else print("its not a leap year") end ---------------------output---------------------- Enter the year 1988 its a leap year
  • 14. --[[Program to Compute Sum of Series 1 + x2/3! + x3/5! + x4/3! + x5/4! + .. + xn/2n-1!]]-- sum=1.00 a=2 fact=1 y=0 print("Enter the value of x,N") x=tonumber(io.read()) N=tonumber(io.read()) while(a<=N) do tmp=x^a fact=1 y=2*a-1 while(y>=1) do fact=fact*y y=y-1 end sum = sum +tmp/fact a=a+1 end print("sum="..sum) -------------------output------------------------- Enter the value of x,N 2 10 sum=1.7365977440172