Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion FizzBuzz/FizzBuzz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@ class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
Console.WriteLine("FizzBuzz");
}
else if (i % 3 == 0)
{
Console.WriteLine("Fizz");
}
else if (i % 5 == 0)
{
Console.WriteLine("Buzz");
}
else
{
Console.WriteLine(i);
}
}
}
}
}
28 changes: 28 additions & 0 deletions sort/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/sort.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions sort/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/sort.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
41 changes: 41 additions & 0 deletions sort/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;

namespace sort
{
class Program
{
static void Main(string[] args)
{
int i;
int[] a = new int[30];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you will move this down to below int n = ... you can create an array only as big as you need.

Console.Write("Enter the Number of values to be Sort : ");
// read the string value and convert it in to integer
int n = Convert.ToInt16(Console.ReadLine());
//Reading the values one by one
for (i = 1; i <= n; i++)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember, everything in C# is zero based indexed. So you are actually creating an array with an unused slot.

{
Console.Write("Enter the No " + i + ":");
// read the string value and convert it in to integer
a[i] = Convert.ToInt16(Console.ReadLine());
}
for (i = 1; i <= n; i++)
{
for (int j = 1; j <= n - 1; j++)
{
if (a[j] > a[j + 1])
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
Console.Write("Ascending Sort : ");
for (i = 1; i <= n; i++)
{
Console.Write(a[i] + " ");
}
//Sort Lowest to Highest
}
}
}
8 changes: 8 additions & 0 deletions sort/sort.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>