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
-
Economics & Finance
Articles by AYUSH MISHRA
112 articles
C# 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. Natural numbers are positive integers starting from 1 (i.e., 1, 2, 3, 4, 5, ...). In this article, we are going to learn how we can find the sum of the first N natural numbers in C#. Sum of First N Natural Numbers N = 5 1 2 3 4 ...
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. The position is counted from the right, starting at 1. In this article, we are going to discuss different approaches to solving this problem using C#. Finding First Set Bit Position Number: 18 Binary: 1 0 0 1 0 ...
Read MoreC# Program to Find Volume, Perimeter and Surface Area of Cuboid
A cuboid is a three-dimensional geometric shape with six rectangular faces, where opposite faces are equal in dimensions. It has three dimensions: length, breadth (width), and height. We can calculate the volume, perimeter, and surface area of a cuboid using specific mathematical formulas. Cuboid Structure Length Breadth Height Formulas The following formulas are ...
Read MoreC# program to calculate compound interest
Compound interest is interest calculated on the initial principal amount plus all previously earned interest. Unlike simple interest, compound interest grows exponentially because the interest itself earns interest in subsequent periods. In this article, we will explore how to calculate compound interest using C#. What is Compound Interest? Compound Interest is the interest that calculates interest on both the initial principal and the accumulated interest from previous periods. This compounding effect causes the investment to grow at an accelerating rate over time. Compound Interest Growth Principal ...
Read MoreC# Program to Calculate the Area of a Circle
A circle is a round two-dimensional shape where all points on the boundary are equidistant from the center. The distance from the center to any point on the circle's edge is called the radius. Calculating the area of a circle is a fundamental geometric operation commonly used in programming. Formula for Circle Area The area of a circle is calculated using the formula − Area = π × r² Where: π (pi) ≈ 3.14159 or Math.PI in C# r is the radius of the circle Circle ...
Read MoreC# Program to Reverse a Number
Reversing a number is a fundamental programming problem where we reverse the digits of an integer. For example, reversing 12345 gives 54321. This article explores different approaches to reverse a number in C#. Problem Description Given an integer, we need to reverse its digits and return the reversed number. The process involves extracting digits from right to left and reconstructing them from left to right. Examples Input: 12345 Output: 54321 Explanation: The digits are reversed from their original order. Input: 8299 Output: 9928 Explanation: The digits 8, 2, 9, 9 become 9, 9, 2, 8. ...
Read MoreC# Program to Return Quadrant in which the Coordinate Lie
The Cartesian coordinate system is divided into four quadrants based on the signs of x and y coordinates. In this article, we will learn how to determine which quadrant a given point lies in using C#. Understanding Quadrants The coordinate plane is divided into four regions called quadrants − Quadrant I: x > 0 and y > 0 (both positive) Quadrant II: x < 0 and y > 0 (x negative, y positive) Quadrant III: x < 0 and y < 0 (both negative) Quadrant IV: x > 0 and y < 0 (x positive, y ...
Read MoreC# Program to Check if an Array is Sorted
We are given an array, and we need to check whether the array is sorted or not. The array can be sorted in either ascending or descending order. In this article, we will discuss different approaches to check if an array is sorted using C#. Problem Examples Input: array = {1, 2, 3, 4, 5} Output: True Explanation: The array is sorted in ascending order. Input: array = {29, 28, 27, 26, 25, 24} Output: True Explanation: The array is sorted in descending order. Input: array = {12, 10, 19, 11, 9} Output: False Explanation: The ...
Read MoreC# Program to Find Prime Numbers Within a Range
In this article, we are going to discuss how we can find prime numbers present within a given range using C#. What are Prime Numbers? Prime numbers are natural numbers greater than 1 that have exactly two factors − 1 and the number itself. They have no other positive divisors. Examples of prime numbers are 2, 3, 5, 7, 11, 13, 17, etc. Key Facts: The smallest prime number is 2, which is also the only even prime number. The number 1 is not a prime number because it has only one factor (itself). All ...
Read MoreC# program to count prime numbers in an array
Prime numbers are natural numbers greater than 1 with exactly two factors: 1 and themselves. Examples include 2, 3, 5, 7, 11, 13, and so on. The smallest prime number is 2, which is also the only even prime number. Problem Description We are given an array and need to find the count of prime numbers present in that array using C#. Below are examples to understand the problem − Examples Input: array = {3, 6, 12, 7, 9, 11} Output: Count = 3 (prime numbers: 3, 7, 11) Explanation: The numbers 3, 7, and 11 ...
Read More