Question

Write an algorithm that performs the following: Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write the word BLUE. if the number is between 25 and 35 , write the word ORANGE. If it is any other number, write that ALL COLOURS ARE BEAUTIFUL.

✨ Free AI Tools for You

Powered by Chatterbot AI

Answer

Here is the algorithm to achieve the mentioned task:

  1. Input: A number from the user

  2. Process: Check which range the number falls into and determine the appropriate output

  3. Output: Depending on the range, output the corresponding word or phrase

Pseudocode

PRINT "Enter a number"
INPUT number

IF 5 <= number < 15 THEN
    PRINT "GREEN"
ELSE IF 15 <= number < 25 THEN
    PRINT "BLUE"
ELSE IF 25 <= number < 35 THEN
    PRINT "ORANGE"
ELSE
    PRINT "ALL COLOURS ARE BEAUTIFUL"

Explanation

  1. Ask the user to enter a number: Start by prompting the user to enter a number.

  2. Check the range of the number:

    • If the number is between 5 and 15 (inclusive of 5 and less than 15), print "GREEN".

    • If the number is between 15 and 25 (inclusive of 15 and less than 25), print "BLUE".

    • If the number is between 25 and 35 (inclusive of 25 and less than 35), print "ORANGE".

    • If the number does not fall into any of these ranges, print "ALL COLOURS ARE BEAUTIFUL".

Each step ensures that the correct message is printed based on the range in which the entered number falls.


Was this helpful?

India's 1st AI Doubt Solver for CBSE, JEE, and NEET

Ask a Question for Free

and then it's just ₹212 a month

Learn how Chatterbot AI can help you succeed

Cover Image of the article Computer Science Class 11 CBSE - The Ultimate Guide with Notes, Solutions and AI

Computer Science Class 11 CBSE - The Ultimate Guide with Notes, Solutions and AI

This ultimate guide for CBSE Computer Science class 11 has detailed notes, NCERT solutions, cheat sheets, and our free AI-powered doubt-solving assistant, Chatterbot AI.

Cover Image of the article JEE Advanced 2024 Exam Date Announced: Complete Guide to Eligibility, Syllabus, and Preparation Tips

JEE Advanced 2024 Exam Date Announced: Complete Guide to Eligibility, Syllabus, and Preparation Tips

JEE Advanced 2024 on May 26! Get exam schedule, syllabus, prep tips & more in this guide. Ace India's top engineering test with topper strategies.

Cover Image of the article How to Crack NEET: The Ultimate Blueprint to Outsmart the Exam and Unlock Your Medical Dreams

How to Crack NEET: The Ultimate Blueprint to Outsmart the Exam and Unlock Your Medical Dreams

Ace NEET with expert strategies: Discover effective exam strategies, time management, core concepts mastery, problem-solving techniques, revision tips, and AI-assisted doubt clearing with Chatterbot AI.

Cover Image of the article How to Crack IIT: Smart Self-Study Strategies and AI Tools for Success

How to Crack IIT: Smart Self-Study Strategies and AI Tools for Success

Ace IIT JEE in 6 months without coaching. Discover expert self-study strategies for Physics, Chemistry, and Math. Master time management, mock tests, and leverage AI tools like Chatterbot AI for personalized doubt-solving.