Build skills in CSharp




How to improve programming skills in CSharp

How to improve programming skills in CSharp requires focus, interest and the ability to judge what you are doing. These things can’t be achieved in a day or two unless and until you decide to learn deeply, being talkative with your professional friends about some ideas and show courage to sit with your computer for longer hours.
The more interaction of yours with the machine, brighter are your chances to excel in the field of programming.
Books are very helpful but you gain introduction to some programming language with your books. They can’t guarantee your success in the field. The practice a lot type of attitude is the key asset to programming. We will program some old school type tasks to further open your mind.
For these things, we will learn how to grip the logic behind complex loops and conditions as well as other tips and tricks;

Task 1: Displaying a pyramid on console

using System;
using System.Text;

namespace Pyramid
{
class Program
{
static void Main(string[] args)
{
int height = 10, blank, decrement;

for (int i = 1; i <= height; i++) { for (blank = 1; blank <= (height - i); blank++) Console.Write(" "); for (decrement = 1; decrement <= i; decrement++) Console.Write("*"); for (decrement = (i - 1); decrement >= 1; decrement–)

Console.Write(“*”);

Console.WriteLine();

}

}
}
}

Output

Task 2: Bubble sorting an array

image credit:wikipedia

Bubble Sorting is a terminology , that illustrates how to sort out all the elements in a data structure such as array. This sorting is based upon the proper placement of the elements in an order.
The elements are said to get bubbled when they rearrange their positions.

using System;
namespace SortedArray
{
class Program
{
static void Main(string[] args)
{
int[] MyArray = {500,200,1000,800,911};

int StoreBuffer;
int MyArrayLength = MyArray.Length;

for (int i = 1; i < MyArrayLength ; i++) { for (int a = 0; a < (MyArrayLength - 1); a++) { if (MyArray[a + 1] > MyArray[a])
{
StoreBuffer = MyArray[a];
MyArray[a] = MyArray[a + 1];
MyArray[a + 1] = StoreBuffer;

}
}
}

foreach (int element in MyArray)
{
Console.Write(“t {0}”,element);
}
Console.Read();
}
}
}

Output


Syed Adeel Ahmed
Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Leave a Reply