Test your knowledge and understanding by answering some questions, get some hands-on practice, and explore this chapter's topics with deeper research.
Answer the following questions:
static
, const
, and readonly
keywords?[Flags]
attribute to an enum
keyword when you want to store combined values?partial
keyword useful?Create a console application named Ch06_Exercise02
and add three static methods to the Program
class to perform the following tasks:
CardinalToOrdinal
that converts a cardinal int
into an ordinal string
, for example, it converts 1 into 1st, 2 into 2nd, and so on.Factorial
that calculates the factorial for an int
variable passed to it as a parameter. You could either use a loop or a technique called recursion, which means a method that calls itself.PrimeFactors
that, when passed an int
variable as a parameter, returns a string
showing the prime factors as stated earlier.In the Main
method, prompt the user to press A, B, or C to choose between the three mathematical functions. Then, prompt the user to enter a number as input and then show the output.
Use the following links to read more about this chapter's topics:
3.138.120.187