Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

solve fizzbuz 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 :: get enum int by name 
Csharp :: unity get list of children 
Csharp :: how to make int to text unity 
Csharp :: unity unparent 
Csharp :: c# read from text documenmt 
Csharp :: remove items from list c# condition 
Csharp :: c# separate string by comma 
Csharp :: c# convert list to string 
Csharp :: C# int.parse input string wasnt in correct format 
Csharp :: destroy gameobject unity 
Csharp :: .net core add header to soap request 
Csharp :: how to check if a value is inside an array c# 
Csharp :: regex c# password numbers and letters 
Csharp :: rigidbody.addtorque 
Csharp :: c# connect to mongodb 
Csharp :: get time part from datetime as timestamp in c# 
Csharp :: C# convert iformfile to stream 
Csharp :: how to add a list to observablecollection in c# 
Csharp :: c# unity get lines 
Csharp :: fluentassertions force exceptions 
Csharp :: fill all array c# with same value 
Csharp :: c# bcrypt 
Csharp :: color picker wpf 
Csharp :: how to get the current time in milliseconds .net 
Csharp :: C# .net core convert string to enum 
Csharp :: c# write byte[] to stream 
Csharp :: enum get all values c# 
Csharp :: movement unity 
Csharp :: listview item click c# 
Csharp :: dota2 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =