Docs Installation Playground Explore AST

Set on System Basis

Fun Programs in BroCode

Time to dive into some cool and simple programs in BroCode! Let’s do something useful, something funny, and maybe even a little weird with your code! 💻😎


Ready for some BroCode magic? Let’s go! 🎩✨

Program 1: "Bro, Let’s Calculate Factorial! 🧮"

Want to calculate the factorial of a number? Let’s see how BroCode makes that easy for you. Factorial is the product of all positive integers up to the number. Let’s flex those math muscles! 💪

BROCODE
bro function calculateFactorial(num) {
  bro maanle result hai 1;
  bro jbb tk (num > 1) hai {
    result = result * num;
    num--;
  }
  bro dikha de("Factorial: " + result);
}

calculateFactorial(5);
Context: This is a simple function to calculate the factorial of a number. Factorial of 5 (5!) is 120. Let’s see it in action!

Program 2: "Bro, Let’s Do Some Math - Adding Numbers! ➕"

Sometimes, all you need is a little bit of addition to brighten your day. Let’s add up a few numbers in BroCode! Simple, but effective math. 🧑‍🏫

BROCODE
bro function addNumbers(a, b) {
  bro dikha de("Sum: " + (a + b));
}

addNumbers(10, 15);
Context: This function adds two numbers and prints the result. It's a quick and easy way to do basic math operations!

Program: "Bro, Let’s Take Care of Our Virtual Pet! 🐶"

Who doesn’t love pets? Let’s simulate taking care of a virtual pet. You can feed it, play with it, and see how it's doing!

BROCODE
bro maanle petHunger hai "hungry";
bro maanle petEnergy hai "low";

bro agar (petHunger == "hungry") hai {
  bro dikha de("Bro, your pet is hungry! Feed it some food. 🍖");
  bro maanle petHunger hai "full";
}
bro agar (petEnergy == "low") hai {
  bro dikha de("Bro, your pet needs some playtime! Let it have fun. 🧸");
  bro maanle petEnergy hai "high";
}
bro dikha de("Your pet is now happy and healthy! 🐾");
Context: This program simulates a virtual pet's needs. It checks if the pet is hungry or low on energy and gives a reminder to feed or play with it. A fun way to get some basic conditionals working!

Program 4: "Bro, Let’s Count Down to Launch! 🚀"

Feeling like a space mission? Let’s countdown together, bro! It’s like launching your next big idea into the world! 🚀

BROCODE
bro function countdown(num) {
  bro jbb tk (num > 0) hai {
    bro dikha de(num);
    num--;
  }
  bro dikha de("Blast off! 🚀");
}

countdown(5);
Context: This function will count down from the number you input. It’s like prepping for a rocket launch, but without all the noise!

Program 5: "Bro, Let’s Check if It’s Even or Odd! 🔢"

Time for a classic! Let’s check if a number is even or odd in BroCode! It’s a great way to practice conditionals. Let’s do this, bro!

BROCODE
bro function checkEvenOdd(num) {
  bro agar (num % 2 == 0) hai {
    bro dikha de(num + " is Even!");
  }
  bro leave it {
    bro dikha de(num + " is Odd!");
  }
}

checkEvenOdd(9);
Context: This simple function checks if a number is even or odd and tells you. A great way to work with conditionals!

Bro, You’re Crushing It!

Keep coding, bro! With every line, you’re building your skills and getting closer to mastering the game. Stay consistent, have fun, and remember – even the best coders started just like you! 💻🚀

Joke: Why don’t variables ever tell secrets?
Because they can’t keep things private! 😜

BroCode © 2024. All rights reserved.