Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Program to ask the user for his age and print a massage


C# Sharp Basic: Exercise-11 with Solution

Write a C# Sharp program that takes an age (for example 20) as input and prints something as "You look older than 20.

C# Sharp Exercises: Program to ask the user for his age and print a massage

Sample Solution:

C# Sharp Code:

using System;
public class Exercise11
{
  public static void Main()
  {
    int age;
    Console.Write("Enter your age ");
    age = Convert.ToInt32(Console.ReadLine());
    Console.Write("You look younger than {0} ",age);
  }
}

Sample Output:

Enter your age 45                                                                                             
You look younger than 45

Flowchart:

Flowchart: C# Sharp Exercises - Program to ask the user for his age and print a massage

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# Sharp program to that takes three numbers(x,y,z) as input and print the output of (x+y)·z and x·y + y·z.
Next: Write a C# program to that takes a number as input and display it four times in a row (separated by blank spaces), and then four times in the next row, with no separation. You should do it two times: Use Console. Write and then use {0}

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.