HI WELCOME TO KANSIRIS
Showing posts with label c# interview programs. Show all posts
Showing posts with label c# interview programs. Show all posts

How to get the total number of decimal places using c#

Leave a Comment
For example, please refer to the sample input and output below.  InputOutput 10 1.00 1.11 1.122 1.1233 1.11002 1.0102 1.001100 4               using System;namespace SampleProgram{    class MainProgram    {        public static void Main(string[] args)        {            // Create the decimal array for sample test data       .

C# Program to compute factorial of a number

Leave a Comment
In mathematics, 5 factorial is computed as 5X4X3X2X1, which is equal to 120. 5 factorial is denoted as 5 and an exclamation mark as shown below.5 Factorial = 5! = 5X4X3X2X1 = 120 4 Factorial = 4! = 4X3X2X1 = 243 Factorial = 3! = 3X2X1 = 6Factorial of Zero is 1.C# Program below shows how to compute factorial for a given number. using System;namespace SamplePrograms{    class Factorial    {        public static void Main()       .

Find smallest and largest number in an integer array

Leave a Comment
I want a c# program that can find and print, the smallest and largest number in a given integer array. using System;using System.Linq;namespace SamplePrograms{    class LargestSmallest    {        public static void Main()        {            // Declare and initialize the integer array            int[] NumbersArray = { 102, 34, 89, 12, 187, 29, 111};   .

Exception handling at its best

Leave a Comment
Write a c# program to add two numbers. This may sound very simple, but the catch, is - The program should not break, and always should give meaningful error messages when exception conditions occur. For example, the following error conditions should be handled in your program. Also, the program should run as long as the user wants it to run.1. If the user enters "Ten" instead of 10, the program should let the user know only numbers can be added.2. If the user, enters a very large number, the program should let the user know.

Insert space before every upper case letter in a string

Leave a Comment
Write a c# program that inserts a single space before every upper case letter. For example, if I have string like "ProductUnitPrice", the program should convert it to "Product Unit Price". Usually database column names will not have spaces, but when you display them to the user, it makes sense to have spaces.using System;using System.Text;namespace SamplePrograms{    class SpaceBeforeUpperCaseLetter    {        public static void Main() .

C# program to remove duplicates

Leave a Comment
Write a c# program to print unique names, by removing the duplicate entries. For example, in the Input String below, Rob and Able names are repeated twice. The c# program that you write should remove the duplicates and return the string as shown in Output String. The output string contains each name only once, eliminating duplicates.Input String    = "Rob;Mike;Able;Sara;Rob;Peter;Able;"Output String = "Rob;Mike;Able;Sara;Peter;"using System;using System.Linq;using System.Text;namespace SamplePrograms{ .

C# program to sort names in ascending and descending order

Leave a Comment
I have a string of user names seperated by semi colon. I want a c# program that can sort these names in both ascending and descending order.string strUserNames = "Rob;Mike;Able;Sara;Peter;John;Tom;Ben"; using System;namespace SamplePrograms{    class SortNamesInAscendingAndDescendingOrder    {        public static void Main()        {            // Prompt the user to enter the list of user names .