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 sudhir sharma
Page 15 of 98
C Program for Reversal algorithm for array rotation
An algorithm is a set of instructions that are performed in order to solve the given problem. Here, we will discuss the reversal algorithm for array rotation and create a program for a reversal algorithm. Now, let's get to some terms that we need to know to solve this problem − Array − A container of elements of the same data type. The size (number of elements) of the array is fixed at the time of the declaration of the array. Array rotation − Rotating an array is changing the order of the elements of the array. ...
Read MoreFind the area of a circle in C programming.
A circle is a closed figure where all points are equidistant from a central point called the center. The distance from the center to any point on the circle is called the radius. To find the area of a circle in C programming, we use the mathematical formula and implement it with proper input handling. Syntax area = π * radius * radius Where π (pi) ≈ 3.14159 and radius is the distance from center to the edge of the circle. Method 1: Using Fixed Radius Value This example calculates the area using ...
Read MoreC Program for Number of stopping station problem
The number of stopping stations problem calculates the ways a train can stop at r stations out of n total stations such that no two stopping stations are consecutive. This is a classic combinatorial problem solved using the formula for selecting non-adjacent elements. Syntax C(n-r+1, r) = (n-r+1)! / (r! * (n-2*r+1)!) Problem Explanation When a train travels from point X to Y with n intermediate stations, we need to find the number of ways to select r stopping stations such that no two selected stations are adjacent. This constraint transforms the problem into ...
Read MoreAdd two numbers represented by two arrays in C Program
A number represented by an array is stored in such a form that each digit of the number is represented by an element of the array. For example − Number 234 in array is {2, 3, 4} To add two such numbers we will first add digits from the least significant position and if the sum is greater than 9, we propagate the carry. We continue this process for consecutive digits until all digits are processed. Syntax void addArrays(int arr1[], int arr2[], int size1, int size2, int result[]); Algorithm To ...
Read MoreC/C++ Tricky Programs
Here are 10 tricky C programming challenges that will test your understanding of language fundamentals and creative problem-solving techniques. 1. Program to Print Double Quotes in C Printing double quotes in C requires escape sequences since quotes are used to delimit string literals. We use the backslash escape sequence " to print quotes − #include int main() { printf(""Tutorials Point ""); return 0; } "Tutorials Point " 2. Print Numbers 1 to 10 Without Loops or Goto When loops and ...
Read MoreC/C++ Program for Greedy Algorithm to find Minimum number of Coins
A greedy algorithm is an algorithmic approach used to find an optimal solution for the given problem. Greedy algorithm works by finding locally optimal solutions (optimal solution for a part of the problem) of each part so that the global optimal solution can be found. In this problem, we will use a greedy algorithm to find the minimum number of coins/notes that could makeup to the given sum. For this we will take under consideration all the valid coins or notes i.e. denominations of { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 }. We need to ...
Read MoreC Program to Find the minimum sum of factors of a number?
The minimum sum of factors of a number is the sum of all prime factors (with repetition) of that number. This approach decomposes the number into its smallest possible factors, which are prime numbers, resulting in the minimum possible sum. Syntax int findMinSumOfFactors(int n); Explanation To find the minimum sum of factors, we need to find all possible ways to factorize the number and compare their sums. The minimum sum is always achieved by using prime factorization − Input: n=12 Output: 7 Following are different ways to factorize 12 and ...
Read MoreC Program to Compute Quotient and Remainder?
Given two numbers dividend and divisor, we need to write a C program to find the quotient and remainder when the dividend is divided by the divisor. In division, we see the relationship between the dividend, divisor, quotient, and remainder. The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder. 55 ÷ 9 = 6 and 1 Dividend Divisor Quotient Remainder Syntax quotient = dividend / divisor; remainder = ...
Read MoreC Program To Check whether Matrix is Skew Symmetric or not?
A square matrix A is said to be skew-symmetric if Aij = −Aji for all i and j. In other words, a matrix A is skew-symmetric if the transpose of matrix A equals the negative of matrix A (AT = −A). Note that all main diagonal elements in a skew-symmetric matrix are zero. Syntax // Check if matrix[i][j] == -matrix[j][i] for all i, j if (A[i][j] == -A[j][i]) { // Matrix is skew-symmetric } Example Matrix Let's take an example of a 3×3 matrix − A = ...
Read MoreC Program for Rat in a Maze - Backtracking-2?
Rat in a maze is a popular problem that utilizes backtracking algorithm. In this problem, we have a 2D matrix representing a maze where some cells are blocked and we need to find a path from source to destination. A maze is a 2D matrix in which some cells are blocked. One of the cells is the source cell, from where we have to start, and another is the destination where we have to reach. We must find a path from source to destination without moving into any blocked cells. Input Maze: ...
Read More