Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Csharp Articles
Page 110 of 196
Binary search in C#
The binary search algorithm works on the divide and conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, the array should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left sub-array, right sub-array, or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element using binary ...
Read MoreFind the Angle Between Hour and Minute Hands of a Clock in C#
The calculation of the angle between the hour and minute hands of a clock is a common problem in Logical Reasoning and programming. This calculation is used in various applications, such as analog clock simulations, scheduling software, and time-based animations In this article, we are going to discuss how we can calculate the angle between the hour and minute hands of a clock in C# using different approaches: What is the Angle Between the Hour and Minute Hands? The angle between the hour and minute hands is determined based on the positions of both hands on the clock ...
Read MoreMaximum Subarray Sum - Kadane Algorithm using C#
In this problem, we are given an array of integers that may contain both positive and negative integers. We have to calculate the maximum sum of any contiguous subarray of the given array. In this article, we are going to learn how we can find the maximum subarray sum using the Kadane Algorithm using C#. Here is an example to find maximum sum in subarray: Example Input: arr = [1, -2, 3, 4, -1, 2, 1, -5, 4] Maximum Sum Subarray: [3, 4, -1, 2, 1] Sum = 3 + 4 + (-1) + 2 + 1 = 9 ...
Read MoreC# program to find first set bit
In this problem, we are given a number n, and we need to find the position of the first set bit (1-bit) in its binary representation. In this article, we are going to discuss different approaches to solving this problem using C#. Example 1 Input: N = 18 Output: 2 Explanation: The binary representation of 18 is 10010. The first set bit from the right is at position 2. Example 2 Input: N = 12 Output: 3 Explanation: The binary ...
Read MoreC# Program to Find Volume, Perimeter and Surface Area of Cuboid
What is a Cuboid? A cuboid is a three-dimensional figure with six rectangular faces, where opposite faces are equal in dimensions. We can calculate the volume, perimeter, and surface area of a cuboid using specific formulas based on its length, breadth, and height. Problem Statement Given length, breadth, and height. You need to find its volume, perimeter, and surface area using different approaches in C#. Formulas for Cuboid Calculations The following are the formulas for the volume, perimeter, and surface area of a cuboid: The Volume of a Cuboid: Volume = length × breadth × height The ...
Read MoreC# Program to Find the Sum of First N Natural Numbers
We are given a number N, and we need to calculate the sum of the first N natural numbers. In this article, we are going to learn how we can find the sum of the first N natural numbers in C#. Example 1 Input: N = 3 Output: 6 Explanation − The first 3 natural numbers are: 1, 2, 3 The sum of these numbers is: 1 + 2 + 3 = 6 Example 2 Input: N = 5 Output: 15 Explanation − The first 5 natural numbers are: 1, 2, 3, 4, 5 ...
Read MoreConvert a number to Roman numerals in C#
Problem Description In this problem, we are given a number, and we need to convert it to its equivalent Roman number representation using C#. Example 1 Input: number = 58 Output: Roman numeral = LVIII Explanation: 58 in Roman numerals is written as L (50) + V (5) + III (3). Example 2 Input: number = 1994 Output: Roman numeral = MCMXCIV Explanation: 1994 in Roman numerals is written as M (1000) + CM (900) + XC (90) + IV ...
Read MoreFind the sum of cubes of the first N natural numbers in C#
Problem Description We are given a number N, and we need to calculate the sum of the cubes of the first N natural numbers. In this article, we are going to learn how we can find the sum of cubes of the first N natural numbers C#. Example 1 Input: N = 3 Output: 36 Explanation: The cubes of the first 3 natural numbers are: 13 = 1, 23 = 8, 33 = 27 The sum of these cubes is:1 + 8 ...
Read MoreCalculate the sum of squares of the first N natural numbers in C#
Problem Description In this problem, we are given a number n, and we need to calculate the sum of the squares of the first N natural numbers. In this article, we are going to discuss different approaches to solving this problem using C#. Example 1 Input: N = 4 Output: 30 Explanation: The squares of the first 4 natural numbers are: 1, 4, 9, 16. The sum of the numbers is: 1 + 4 + 9 + 16 = 30. Example 2 Input: ...
Read MoreRemove all even numbers from an array in C#
Natural numbers are a set of positive integers, which are commonly used for counting and ordering. They begin from 1 and continue infinitely. In some contexts, it may also include 0. Here, we are going to learn about different approaches to removing all odd numbers from a given array using C#. Problem Description We are given an array and need to remove all the even numbers from it. The resulting array should only contain odd numbers. In this article, we are going to discuss different approaches to solving this problem using C#. Example 1 Input: array ...
Read More