Skip to main content

Challenge 6: Share Pizza Safely! 🚀

Welcome to this challenge! Work with Robo 🤖 to solve this problem step-by-step using algorithms and flowcharts.

🎬 The Story

Robo wants to share $4$ pizzas equally between $2$ children. Help Robo divide them, but make sure to check if the number of children is $0$ first, as dividing by zero is impossible!

📝 The Algorithm

  1. Start (Begin)
  2. Read Number1 and Number2 (Input)
  3. Check if Number2 is 0 (Decision)
    • If Yes: Display "Cannot divide by zero" (Output), then go to step 6 (Stop)
    • If No: Proceed to step 4
  4. Divide Number1 by Number2 and store in quotient (Process)
  5. Display quotient (Output)
  6. Stop (End)

📊 The Flowchart

Here, the pink Decision Diamond is introduced.


💻 From Flowchart to Code

Here is how to divide two input numbers with zero check safety in Python, Java, and C:

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

# Check for division by zero
if num2 == 0:
print("Cannot divide by zero")
else:
ans = num1 / num2
print("Quotient:", ans)

🔗 Next Steps

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir