Server Side Programming Articles

Page 759 of 2109

C# Program to Check Whether the Entered Number is an Armstrong Number or Not

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

An Armstrong number (also called a narcissistic number) is a number that equals the sum of its digits raised to the power of the number of digits. For a 3-digit number, each digit is cubed and summed. For example, 153 is an Armstrong number because − 1³ + 5³ + 3³ = 1 + 125 + 27 = 153 Armstrong Number Check Process 153 Original Number 1³ + 5³ + 3³ Sum of Cubes ...

Read More

C# program to convert a list of characters into a string

Samual Sam
Samual Sam
Updated on 17-Mar-2026 1K+ Views

Converting a list of characters into a string is a common operation in C#. There are several approaches to accomplish this task, each suitable for different scenarios and data structures. Syntax Following are the main syntax patterns for converting characters to strings − // Using string constructor with char array string result = new string(charArray); // Using string.Join() method string result = string.Join("", charList); // Using StringBuilder class StringBuilder sb = new StringBuilder(); sb.Append(charArray); string result = sb.ToString(); Using String Constructor with Character Array The most direct approach is using the ...

Read More

C# program to count the number of words in a string

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 8K+ Views

In C#, counting the number of words in a string can be accomplished using various approaches. The most common method involves iterating through each character and identifying word separators like spaces, tabs, and newlines. Using Character-by-Character Iteration This approach loops through the string and counts whitespace characters to determine word boundaries − using System; public class Demo { public static void Main() { int a = 0, myWord = 1; string str = "Hello World!"; if (str.Length == 0) { myWord = 0; } else { while (a

Read More

C# program to count occurrences of a word in string

Samual Sam
Samual Sam
Updated on 17-Mar-2026 4K+ Views

Counting occurrences of a specific word in a string is a common string manipulation task in C#. This can be achieved using various approaches like the IndexOf() method, regular expressions, or LINQ methods. Using IndexOf() Method The IndexOf() method searches for the first occurrence of a substring and returns its position. By combining it with a loop, we can count all occurrences − using System; class Program { static void Main() { string str = "Hello World! Hello Universe! Hello!"; ...

Read More

C# program to convert binary string to Integer

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 1K+ Views

Converting a binary string to an integer in C# can be accomplished using several methods. The most straightforward approach is using Convert.ToInt32() with base 2, but you can also implement manual conversion for better understanding of the binary-to-decimal process. Using Convert.ToInt32() Method The simplest way to convert a binary string to an integer is using the built-in Convert.ToInt32() method with base 2 − using System; class Program { static void Main() { string binaryStr = "1001"; ...

Read More

C# Program to Convert Character case

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 644 Views

Converting character case in C# is a common string manipulation task. The string class provides built-in methods ToLower() and ToUpper() to convert strings to lowercase and uppercase respectively. Syntax Following is the syntax for converting string case − string.ToLower() // Converts to lowercase string.ToUpper() // Converts to uppercase Both methods return a new string with the case converted and do not modify the original string. Using ToLower() Method The ToLower() method converts all uppercase characters in a string to lowercase − using System; ...

Read More

C# Program to convert Digits to Words

Samual Sam
Samual Sam
Updated on 17-Mar-2026 4K+ Views

Converting digits to words in C# involves breaking down a number into its individual digits and mapping each digit to its corresponding word representation. This technique is commonly used in financial applications, report generation, and number-to-text conversion systems. Algorithm Overview The conversion process follows these steps − Create an array of word strings for digits 0-9 Extract each digit from the number using modulo operation Store digits in reverse order (rightmost digit first) Map each digit to its corresponding word and display in correct order Digit-to-Word Conversion Process ...

Read More

C# Program to Convert Decimal to Binary

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 1K+ Views

Converting a decimal number to binary involves repeatedly dividing the decimal number by 2 and collecting the remainders. In C#, this can be accomplished using manual division or built-in methods like Convert.ToString(). The manual approach uses the division by 2 method where we divide the decimal number by 2, store the remainder, and continue until the quotient becomes 0. The binary representation is formed by reading the remainders in reverse order. Using Manual Division Method This method involves dividing the decimal number by 2 repeatedly and collecting remainders − Decimal to Binary ...

Read More

C# Program to Convert Fahrenheit to Celsius

Samual Sam
Samual Sam
Updated on 17-Mar-2026 3K+ Views

Temperature conversion between Fahrenheit and Celsius is a common programming task. In C#, you can easily convert Fahrenheit to Celsius using a simple mathematical formula and display the results with proper formatting. The conversion formula subtracts 32 from the Fahrenheit temperature, then multiplies by 5/9 to get the equivalent Celsius temperature. Formula The mathematical formula for converting Fahrenheit to Celsius is − celsius = (fahrenheit - 32) * 5 / 9 Fahrenheit to Celsius Conversion 97°F - 32 × 5/9 ...

Read More

C# Program to convert first character uppercase in a sentence

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 567 Views

Converting the first character of each word to uppercase in a sentence is a common text formatting task in C#. This process involves identifying word boundaries and converting the first lowercase letter of each word to its uppercase equivalent. Syntax Following is the basic approach to convert characters from lowercase to uppercase − char uppercaseChar = (char)(lowercaseChar - 'a' + 'A'); To check if a character is a lowercase letter − if (ch >= 'a' && ch = 'a' && val[i] = 'A' && val[i] word.Length > 0 ? ...

Read More
Showing 7581–7590 of 21,090 articles
« Prev 1 757 758 759 760 761 2109 Next »
Advertisements