C# Sharp Exercises: Reverse a boolean value
C# Sharp Basic: Exercise-87 with Solution
Write a C# Sharp program to reverse a boolean value.
Sample Solution:
C# Sharp Code:
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
bool cat = false;
bool dog = true;
Console.WriteLine("Original value: "+cat);
Console.WriteLine("Reverse value: "+test(cat));
Console.WriteLine("Original value: "+dog);
Console.WriteLine("Reverse value: " + test(dog));
}
public static bool test(bool boolean)
{
return !boolean;
}
}
}
Sample Output:
Original value: False Reverse value: True Original value: True Reverse value: False
Flowchart:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to get the number of letters and digits in a given string.
Next: Write a C# Sharp program to find the sum of the interior angles (in degrees) of a given Polygon. Input number of straight line(s).
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework