Write a program to Calculate total no of possible square count that is possible . if user give 1 then output will be 1 if user give 2 then output will be 5 if user give 3 then output will be 14 and so on

using System;   namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int noOfSquare = 0; Console.WriteLine(“Please enter input”); int input = int.Parse(Console.ReadLine()); Console.Write(“Total No Of Square is:”); for(int i=1;i<=input;i++) { noOfSquare = noOfSquare + Power(i); } Console.WriteLine(noOfSquare); } public static int Power(int input) { return input * input; } } } Advertisements Continue reading Write a program to Calculate total no of possible square count that is possible . if user give 1 then output will be 1 if user give 2 then output will be 5 if user give 3 then output will be 14 and so on

Write a program to Convert decimal To Binary in c#

using System; class myclass { static void Main() { int num; Console.Write(“Enter a Number : “); num = int.Parse(Console.ReadLine()); int quot; string rem = “”; while (num >= 1) { quot = num / 2; rem += (num % 2).ToString(); num = quot; } // Reversing the  value string bin = “”; for (int i = rem.Length – 1; i >= 0; i–) { bin = bin + rem[i]; } Console.WriteLine(“The Binary format for given number is {0}”,bin);   Console.Read(); } } Continue reading Write a program to Convert decimal To Binary in c#

Write a Program to find LCM and GCD or HCF of two number in C#

First Way ———————————— using System; class myclass { static void Main() { int i1, i2; Console.WriteLine(“Enter 2 numbers to find GCD”); i1 = int.Parse(Console.ReadLine()); i2 = int.Parse(Console.ReadLine()); int n1, n2; //Making sure n1 is greater than n2 if (i1 > i2) { n1 = i1; n2 = i2; } else { n1 = i2; n2 = i1; } int result = gcd(n1, n2); Console.WriteLine(“The GCD of {0} and {1} is {2}”,i1,i2,result); Console.Read(); } private static int gcd(int n1, int n2) { int rem = 5; while (n2 > 0) { rem = n1 % n2; if (rem == 0) return n2; n1 = n2; n2 = rem; } //gcd of any number with 0 is number itself. return n1; } } … Continue reading Write a Program to find LCM and GCD or HCF of two number in C#

Bubble sort in c#

using System; class Program { static void Main() { int[] a = { 4, 6, 9, 83, 34, 45 }; int temp; for (int pass = 1; pass <= a.Length – 2; pass++) { for (int i = 0; i <= a.Length – 2; i++) { if (a[i] > a[i + 1]) { temp = a[i + 1]; a[i + 1] = a[i]; a[i] = temp; } } } Console.WriteLine(“The Sorted array”); foreach (int aa in a) Console.Write(aa + ” “); Console.Read(); } } Continue reading Bubble sort in c#

Write a Program to find total count of vowel in a sentences

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace practice {     class Program     {         static void Main(string[] args)         {             string input = “My Name Is vaibhav”;             Console.WriteLine(“Number Of Vowel is:”);             Console.WriteLine(“Count of A is:” + VowelCount(‘A’, input));             Console.WriteLine(“Count of E is:” + VowelCount(‘E’, input));             Console.WriteLine(“Count of I is:” + VowelCount(‘I’, input));             Console.WriteLine(“Count of O is:” + VowelCount(‘O’, input));             Console.WriteLine(“Count of U is:” + VowelCount(‘U’, input));         }         public static int VowelCount(Char VowelCharacter,string input)         {             int vowelCount = 0;             int length = input.Length – 1;             for (int i = 0; i < length; i++)             {                 if (input[i].ToString().ToUpper() == VowelCharacter.ToString().ToUpper()) { vowelCount++; }             }             return vowelCount;         }     } } Continue reading Write a Program to find total count of vowel in a sentences

Difference Between Temporary Table and Table Variable

Both Temporary Tables (# Tables) and Table Variables ( @ Tables) in Sql Server provide a mechanism for Temporary holding/storage of the result-set for further processing. Below table lists out some of the major difference between Temporary Table and Table Variable. Each of these differences are explained in-detail with extensive list of examples in the next articles in this series which are listed above. 1. SYNTAX Below is the sample example of Creating a Temporary Table, Inserting records into it, retrieving the rows from it and then finally dropping the created Temporary Table. — Create Temporary Table CREATE TABLE #Customer (Id INT, Name VARCHAR(50)) … Continue reading Difference Between Temporary Table and Table Variable