Tutorials Point, posted on 6th Mar, 2018

Lolcode Program to Calculate the Factorial of a Number

HAI 1.3
HOW IZ I FACTORIAL YR N
BOTH SAEM N AN 0
O RLY?
YA RLY, FOUND YR 1
NO WAI
FOUND YR PRODUKT OF N AN I IZ FACTORIAL YR DIFF OF N AN 1 MKAY
OIC
IF U SAY SO
VISIBLE I IZ FACTORIAL YR 6 MKAY
KTHXBYE

Tutorials Point, posted on 6th Mar, 2018

Lolcode Program to Make an Array

HAI 1.3
   OBTW
      CREATES A ONE DIMENSIONAL ARRAY WITH N ELEMENTS, EACH IS A 0
   TLDR
	HOW IZ I MAKEMATRIX YR N
      I HAS A MATRIX ITZ A BUKKIT
      IM IN YR LOOP UPPIN YR INDEX TIL BOTH SAEM INDEX N
         MATRIX HAS A SRS INDEX ITZ 10
      IM OUTTA YR LOOP
  
      FOUND YR MATRIX
   IF U SAY SO

      I HAS A N ITZ 5
      I HAS A MATRIX ITZ A BUKKIT
      MATRIX R I IZ MAKEMATRIX YR N MKAY

	   BTW PRINTS THE CONTENTS OF THE ARRAY
      IM IN YR LOOP UPPIN YR INDEX TIL BOTH SAEM INDEX N
         VISIBLE MATRIX'Z SRS INDEX
   IM OUTTA YR LOOP
KTHXBYE

Tutorials Point, posted on 6th Mar, 2018

Lolcode Program to Calculate the Power of a Number

HAI 1.2
HOW IZ I POWERTWO YR NUM
   BTW RETURN 1 IF 2 TO POWER OF 0
   BOTH SAEM NUM AN 0, O RLY?
   YA RLY, FOUND YR 1
   OIC
  
   BTW CALCULATE 2 TO POWER OF NUM
   I HAS A INDEX ITZ 0
   I HAS A TOTAL ITZ 1
   IM IN YR LOOP UPPIN YR INDEX TIL BOTH SAEM INDEX AN NUM
   TOTAL R PRODUKT OF TOTAL AN 2
   IM OUTTA YR LOOP
  
   FOUND YR TOTAL
   IF U SAY SO
   BTW OUTPUT: 8
   VISIBLE I IZ POWERTWO YR 4 MKAY
KTHXBYE

Tutorials Point, posted on 6th Mar, 2018

Lolcode Functions

HAI 1.2
I HAS A STRINGARRAY ITZ A BUKKIT
   STRINGARRAY HAS A VAR17 ITZ "OBJECT1"
   STRINGARRAY HAS A VAR18 ITZ "OBJECT2"
   HOW IZ STRINGARRAY ACCESS YR VARIABLE
      FOUND YR STRINGARRAY'Z SRS VARIABLE
   IF U SAY SO
   I HAS A STRING ITZ "VAR17"
   VISIBLE STRINGARRAY IZ ACCESS YR STRING MKAY
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode Loops

HAI 1.2
I HAS A VAR ITZ 0
IM IN YR LOOPY UPPIN YR VAR TIL BOTH SAEM VAR AN 10
   VISIBLE SUM OF VAR AN 1
IM OUTTA YR LOOPY
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode I/O from Terminal

HAI 1.2
   I HAS A VAR ITZ A YARN BTW DECLARE A VARIABLE FOR LATER USE
   VISIBLE "TYPE SOMETHING AND ENTER"
   GIMMEH VAR BTW GET INPUT (STRING) INTO VARIABLE
   VISIBLE VAR
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode Type Casting

HAI 1.2
I HAS A food ITZ "111.00033"
VISIBLE food

BTW this is how we do type casting
MAEK food A NUMBAR
VISIBLE food
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode Concatenation of Values

HAI 1.2
I HAS A VAR1 ITZ A YARN
VAR1 R "TRUE"

I HAS A VAR2 ITZ A YARN
VAR2 R "ANOTHER TRUE"

I HAS A VAR3 ITZ A YARN
VAR3 R "ONE MORE TRUE"
VISIBLE SMOOSH VAR1 " " VAR3 " " VAR2 MKAY
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode Comparison

HAI 1.2
I HAS A VAR11 ITZ 7
BOTH SAEM VAR11 SMALLR OF VAR11 AN 8, O RLY?
YA RLY
VISIBLE "TRUE"
NO WAI
VISIBLE "FALSE"
OIC
KTHXBYE

Tutorials Point, posted on 5th Mar, 2018

Lolcode Mathematical Operations

HAI 1.2
   I HAS A m ITZ 4
   I HAS A n ITZ 2
VISIBLE SUM OF m AN n      BTW +
VISIBLE DIFF OF m AN n     BTW -
VISIBLE PRODUKT OF m AN n  BTW *
VISIBLE QUOSHUNT OF m AN n BTW /
VISIBLE MOD OF m AN n      BTW modulo
VISIBLE BIGGR OF m AN n    BTW max
VISIBLE SMALLR OF m AN n   BTW min
KTHXBYE

Advertisements
Loading...