C#: Program to ask the user for his age and print a massage
Print Age Message
Write a C# Sharp program that takes an age (for example 20) as input and prints something like "You look older than 20".

Sample Solution:
C# Sharp Code:
using System;
// This is the beginning of the Exercise11 class
public class Exercise11
{
// This is the main method where the program execution starts
public static void Main()
{
int age; // Variable to store the user's age
// Prompting the user to enter their age
Console.Write("Enter your age ");
// Reading the age entered by the user and converting it to an integer
age = Convert.ToInt32(Console.ReadLine());
// Displaying a message indicating that the user looks younger than their entered age
Console.Write("You look younger than {0} ", age);
}
}
Sample Output:
Enter your age 45 You look younger than 45
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C# program to read an age and print different messages depending on whether the age is a prime number.
- Write a C# program to print a message stating how many years until the user turns 100.
- Write a C# program to input age and generate a customized string message based on age brackets using switch-case.
- Write a C# program that accepts an age and outputs a message with each digit of the age written in words.
Go to:
PREV : Specified Formula with Three Numbers.
NEXT : Repeat Number in Rows.
C# Sharp Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.