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.
Showing posts with label c# interview programs. Show all posts
Showing posts with label c# interview programs. Show all posts
Reverse characters in a string
Write a C# program to print the characters in a string in the reverse order.
using System;using System.Collections.Generic;using System.Linq;namespace SamplePrograms{ class ReverseCharacters { public static void Main() { // Prompt the user to enter the string Console.WriteLine("Please enter your string"); .
Build a simple calculator using c# programming language.
The calculator should have the following features.1. Adding 2 Numbers2. Subtracting 2 Numbers3. Multiplying 2 Numbers4. Dividing 2 NumbersAlso, the program should run as long as the user wants it to be running.
using System;namespace SamplePrograms{ class SimpleCalculator { public static void Main() { string UserSelection = string.Empty; do .
C# program to count emails by domain
I have a string of emails seperated by semi colon as shown below. string UserInputEmails = "aa@xyz.com;cc@abc.com;bb@abc.com;dd@abc.com";Write a c# program, that lists the total number of emails by domain. The program should give the following output.Domain = xyz.com & Count = 1Domain = abc.com & Count = 3
using System;using System.Linq;namespace SamplePrograms{ class CountEmailsByDomain { public static void Main() { .
Power function in C#
Write a Power() function. The function should take 2 parameters - Base and Exponent. The function should return back the result of "Base raised to the power of exponent". Let me give an example.When the Power() method is called using parameters 3 and 4 as shown below. The value of 3 to the power of 4 should be returned back, i.e 81.So in short Power(3,4) should return 81. So in this example 3 is the base and 4 is the exponent.
using System;
namespace.
C# program to print alphabets
This c# program prints both upper and lower case alphabets using 2 different approaches.
using System;namespace SamplePrograms{ class Alphabets { public static void Main() { // Loop from a thru z (lower case alphabets) for (char alphabet = 'a'; alphabet <= 'z'; alphabet++) { .
C# program to print multiplication table
This program can be used to print any multiplication table until any number
using System;namespace SamplePrograms{ class NumberTable { public static void Main() { // Prompt the user to enter number for multiplication table Console.WriteLine("For which number do you want to print multiplication table"); // Read the number.
C# program to print fibonacci series
A prime number is not divisible by any other number apart from 1 and itself. So, we use this logic in this program to determine if a number is prime.
using System;namespace SamplePrograms{ class FibonacciSeries { public static void Main() { // Prompt the user to enter their target number Console.WriteLine("How many numbers do you want.
C# program to print prime numbers
A prime number is not divisible by any other number apart from 1 and itself. So, we use this logic in this program to determine if a number is prime.
using System;
namespace SamplePrograms
{
class PrimeNumber
{
public static void Main()
{
// Declare a boolean variable to determine is if a number is prime
bool isNumberComposite = false;
.
C# program to print even numbers
This is a sample C# program to print even numbers. There are 2 ways to to print even numbers.1. Start at Zero. Increment the value by 2, print it. Do this until you reach your target number.2. Start at Zero. Divide the number by 2. If the remainder is zero, then you know the number is even. So print it and then increment it by 1 and divide the number by 2 again. Repeat this until we reach our target number.This program can also be used to print odd numbers by making a minor logic change. Initialize the targetNumber.
How to remove trailing zeros in a decimal - C# Program
For example, consider the sample input and expected output below.
InputOutput
1.01
1.011.01
1.00101.001
0.000
1.0050 1.005
using System;
namespace SampleProgram
{
class MainProgram
{
public static void Main(string[] args)
{
decimal[] decimalNumbers = { 1.0M, 1.01M, 1.0010M, 0.00M, 1.0050M};
foreach (decimal decimalNumber in.