Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: if, else-if, else | Control Structures
C# Basics

bookChallenge: if, else-if, else

Task

Swipe to start coding

Write a program that reads an integer age from the user and prints the user's category based on the following rules:

  • If the age is less than 18, print "child";
  • If the age is 18 or older but less than 65, print "adult";
  • If the age is 65 or older, print "senior".

Use if, else if, and else statements to implement this logic. Only print the category name ("child", "adult", or "senior").

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 10
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

bookChallenge: if, else-if, else

Swipe to show menu

Task

Swipe to start coding

Write a program that reads an integer age from the user and prints the user's category based on the following rules:

  • If the age is less than 18, print "child";
  • If the age is 18 or older but less than 65, print "adult";
  • If the age is 65 or older, print "senior".

Use if, else if, and else statements to implement this logic. Only print the category name ("child", "adult", or "senior").

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 10
single

single

some-alt