C# Programming Exercises for Intermediate Developers offers a comprehensive resource tailored to individuals advancing from basic to intermediate proficiency in C# programming. This section presents a curated selection of exercises designed to challenge and expand the skills of developers who have already mastered the fundamentals of C#. Covering a broad spectrum of intermediate-level topics such as object-oriented programming, asynchronous programming, and advanced data structures, each exercise is meticulously crafted to deepen understanding and promote growth. Whether utilized for self-study or as part of a structured learning curriculum, this inclusive guide empowers intermediate developers to refine their C# skills and tackle more complex programming challenges with confidence.
Functions: greeting + farewell Write a C# program whose Main must be like this:
public static void Main()
{
SayHello();
SayGoodbye();
}
SayHello and SayGoodbye are functions that you must define and that will be called from inside Main. |
Function with parameters Write a C# program whose Main must be like this:
public static void Main()
{
SayHello("John");
SayGoodbye();
}
SayHello and SayGoodbye are functions that you must define and that will be called from inside Main. As you can see in the example. SayHello must accept an string as a parameter. |
Function returning a value Write a C# program whose Main must be like this:
public static void Main()
{
int x= 3;
int y = 5;
Console.WriteLine( Sum(x,y) );
}
"Sum" is a function that you must define and that will be called from inside Main. As you can see in the example, it must accept two integers as parameters, and it must return an integer number (the sum of those two numbers).
|
Function returning a value V2 Write a C# program whose Main must be like this:
public static void Main()
{
__Console.WriteLine("\"Hello, how are you\" contains {0} spaces", ____CountSpaces("Hello, how are you") );
}
CountSpaces is a function that you must define and that will be called from inside Main.
As you can see in the example, it must accept an string as a parameter, and it must return an integer number (the amount of spaces in that string). |
Function write centered Write a C# function to write centered on screen the text that is indicated as a parameter (supposing a screen width of 80 characters):
WriteCentered("Hello!"); |
Function write underlined Write a C# function able to write centered on screen the text that is indicated as a parameter (supposing a screen width of 80 characters) and then underline it (writing several hyphens under that word):
WriteUnderlined("Hello!"); |
Function sum of array Write a C# program to calculate the sum of the elements in an array. "Main" should be like this:
public static void Main()
{ int[] example = {20, 10, 5, 2 };
Console.WriteLine(
__"The sum of the example array is {0}", __Sum(example));
}
}
|
Function double Write a C# function named "Double" to calculate and return an integer number doubled. For example. Double(7) should return 14. |
Function Double reference parameter Write a C# function named "Double" to calculate the double of an integer number, and modify the data passed as an argument. It must be a "void" function and you must use "refererence parameters". For example.
x = 5;
Double(ref x);
Console.Write(x);
would display 10 |
Function swap reference parameters Write a C# function named "Swap" to swap the values of two integer numbers, which are passed by reference.
An example of use might be:
int x=5, y=3;
Swap(ref x, ref y);
Console.WriteLine("x={0}, y={1}", x, y);
(which should write "x=3, y=5") |
Showing 11 to 20 of 57 entries
List of C# Programming Exercises for Intermediate Grouped
All levels of the C# language and for everyone
C# Programming Exercises for all levels. Whether you are a beginning programmer or an advanced programmer. You can practice C# Programming Exercises online, easy and fast