Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

fizzbuzz in c#

// if you don't know what FizzBuzz is than read the next lines

// FizzBuzz is one of the most famous programming 
// problems to solve for exercise.
// the user inputs a number and
// if the number is devided by 3 and has no remainder left print Fizz.
// if the number is devided by 5 and has no remainder left print Buzz.
// if the number is devided by both and has no remainder left print FizzBuzz.
// if it does have a remainder print the number

static string FizzBuzz(int n)
{
	if (n % 3 == 0 && n % 5 == 0)
    {
        return "FizzBuzz";
    }
    else if (n % 5 == 0)
    {
        return "Buzz";
    }
    else if (n % 3 == 0)
    {
        return "Fizz"
    }
    else 
    {
    	return num.ToString();
    }
}

// wait before closing
Console.ReadKey();
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# dynamic object get value 
Csharp :: how to parse a string to an integer c# 
Csharp :: make an object disappear from a c# script unity 
Csharp :: C# get enum value by DescriptionAttribute 
Csharp :: unity agent bake not derecting mesh 
Csharp :: delete all dir content c# 
Csharp :: unity mouse movement 
Csharp :: if cluse in class in vue 
Csharp :: how to remove raycast on a button unity 
Csharp :: wpf update listview itemssource 
Csharp :: stop flickering 
Csharp :: js invoke async function blazor 
Csharp :: built in methods to order a list c# 
Csharp :: nearest greater to right 
Csharp :: unity hide in inspector 
Csharp :: unity making a coroutine wait until another coroutine is done 
Csharp :: c# linq to dictionary 
Csharp :: c# split string into characters 
Csharp :: c# average of 3 numbers 
Csharp :: void to action c# 
Csharp :: unity waituntil coroutine 
Csharp :: tinyint in c# 
Csharp :: c# compile into an exe 
Csharp :: c# object to dictionary 
Csharp :: unity3d remove parent 
Csharp :: c# number in range 
Csharp :: how to get parent gameobject in unity 
Csharp :: httpclient soap request c# 
Csharp :: unity find gameobject 
Csharp :: how to clone something unity 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =