This program will group the sequence of a number from the list with (-), for this example input 1,2,3,4 the output will be 1-4. If there is no sequence of the number then it should be printed as it is, example: 1,3,10 will provide the following output 1,3,10. Program Output: Enter the number: 1,2,3,4,10,11,12,20,100 1-4,10-12,20,100
Tag: Basic program
Description As per Wiki, Happy Number – A happy number is a number defined by the following process: Starting with any positive integer, replace thenumber by the sum of the squares of its digits, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that does not include 1, 7, 10, 13, […]

Whenever we want to declare a variable to our C# program, we need to define “type” and its “name“. Type represent that what kind of variable it is going to store. eg: string, int, float, double, bool etc. Name is used to call that variable, there is no pre-defined name for variable. You can use any […]

In our program we are going to use Object as our data source, if you want to understand LINQ query completely read this article How to understand LINQ Query. Basic LINQ Program using System; using System.Linq; namespace LinqQuery2 { class Program { static void Main(string[] args) { String[] myInput = new string[] { “one”, “two”, […]
LINQ (Language Integrated Query) When creating a dynamic Web Application, you need to retrieve data from various data sources such as flat file, xml file, or a database. To access data from these disparate data sources, you need to learn and implement different techniques to retrieve an data from data source. This complicates your task […]

Read “how to reverse an string” to understand palindrome program. Program using System; namespace PalindromeOrNot { class Program { static void Main(string[] args) { string input, output; Console.WriteLine(“Enter an String to check for Palindrome : “); input = Console.ReadLine(); char[] pal=input.ToCharArray(); Array.Reverse(pal); output= new string(pal); if(input==output) { Console.WriteLine(“The given string is Palindrome !”); } else […]

This is an simple C# program to reverse a string Program using System; namespace StringReverseProgram { class Program { static void Main(string[] args) { string input, output; Console.Write(“Enter an string to reverse: “); input = Console.ReadLine(); //Converting an String datatype to Char Array datatype for easy reverse operation char[] rev = input.ToCharArray(); Array.Reverse(rev); //Again converting […]
Explanation If given value is 125, Divide 125/10, you will get remainder 5 and quotient 12. Store that 5 into output and store quotient into input. Again divide an input 12/10, you will get remainder 2 and quotient 1. Store that 2 into output as 5*10+2, so the value will be 52. Perform these above step […]