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
Server Side Programming Articles
Page 949 of 2109
Find 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 unsigned numbers using bits in C++.
In this problem, we are given two unsigned numbers, and we need to add them using bits in C. Bits are binary digits that can be either 0 or 1. Unsigned numbers are positive numbers represented by these bits. To add two unsigned numbers, we add their bits one by one using binary addition rules. Syntax unsigned int addBits(unsigned int a, unsigned int b); Binary Addition Rules Binary addition works like decimal addition, but with simpler rules − 0 + 0 = 0 0 ...
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 MoreDifference between Compile Time Errors and Runtime Errors in C Program
Errors in C programming are interruptions that prevent code from executing successfully. Based on when they occur, errors can be classified into two main categories: compile time errors and runtime errors. Syntax // Compile Time Error Example int x = 10 // Missing semicolon // Runtime Error Example int result = 10 / 0; // Division by zero Comparison Table Sr. No. Key Compile Time Errors Runtime Errors 1 Definition Errors related to syntax or semantics detected during compilation Errors that occur ...
Read MorePrint matrix in zag-zag fashion in C Programming.
In C programming, printing a matrix in zig-zag fashion means traversing the matrix diagonally while alternating the direction of traversal. This creates a zig-zag pattern where elements are visited along diagonals, first from top-left to bottom-right, then from bottom-right to top-left, and so on. 10 20 30 40 50 ...
Read MorePrint matrix in snake pattern from the last column in C Programming.
In C, printing a matrix in snake pattern from the last column means traversing the matrix row by row, alternating the direction of column traversal. For odd-numbered rows (index 0, 2, 4...), we print from right to left, and for even-numbered rows (index 1, 3, 5...), we print from left to right. Matrix Snake Pattern from Last Column 10 20 30 40 ...
Read MorePrint matrix in snake pattern in C Programming.
In C programming, printing a matrix in snake pattern means traversing the matrix row by row where even-indexed rows are printed from left to right and odd-indexed rows are printed from right to left. This creates a snake-like zigzag pattern through the matrix elements. ...
Read More