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 942 of 2109
Binary to Gray code using recursion in C program
A Binary number is a number that has only two bits 0 and 1. Gray code is a special type of binary number that has a property that two successive numbers of the code cannot differ by more than one bit. This property of gray code makes it useful in K-maps, error correction, communication, etc. This makes the conversion of binary to gray code necessary. So, let's see an algorithm to convert binary to gray code using recursion. Syntax int binaryToGray(int binary); Algorithm Step 1: For input n: Step ...
Read MoreBinary Search for Rational Numbers without using floating point arithmetic in C program
In this problem, we are given a sorted array of rational numbers and we have to search the given element using binary search algorithm without using floating point arithmetic. A Rational number is a number represented in the form p/q where both p and q are integers. For example, 2/3, 1/5. Binary search is a searching technique that works by finding the middle of the array and comparing elements to determine which half contains the target. For finding the element using binary search from a sorted array of rational numbers, where floating point arithmetic is not allowed, ...
Read MoreC program to delete a file
In programming, working with files is very important and every programming language has its own set of functions or library that help in manipulation of files. In C Programming Language, the remove() function can be used by the programmer to delete a file. Syntax int remove(const char *filename); Parameters The function accepts one parameter which is the name of the file that is to be deleted. File name can also be the path to the file but only if the system supports it. filename − A string containing the name of the ...
Read MoreC program to find the Roots of Quadratic equation
In this tutorial, we will be discussing a program to find the roots of a quadratic equation using the quadratic formula. Given a quadratic equation of the form ax2 + bx + c = 0, our task is to find the roots x1 and x2 of the given equation. For this, we use the discriminant method where the discriminant D = b2 - 4ac determines the nature of the roots. Syntax D = b*b - 4*a*c x1 = (-b + sqrt(D)) / (2*a) x2 = (-b - sqrt(D)) / (2*a) Nature of Roots ...
Read MoreC Program for Hexagonal Pattern
We are given with an integer 'n' and the task is to generate the hexagonal pattern and display the final output. Syntax void pattern(int n); Example Let's see the hexagonal pattern for n=5 and n=4 − Input: n=5 Output: * * * * * * * * * * * * * * ...
Read MoreC Program for Circumference of a Parallelogram
We are given the sides of a parallelogram and the task is to calculate the circumference of the parallelogram with its given sides and display the result. What is a Parallelogram? A parallelogram is a type of quadrilateral which has − Opposite sides parallel and equal Opposite angles equal Diagonals bisect each other In the below figure, 'a' and 'b' are the sides of a parallelogram where parallel sides are shown. a a b b ...
Read MoreC program for Binomial Coefficients table
Given with a positive integer value let's say 'val' and the task is to print the value of binomial coefficient B(n, k) where, n and k be any value between 0 to val and hence display the result. What is Binomial Coefficient Binomial coefficient (n, k) is the order of choosing 'k' results from the given 'n' possibilities. The value of binomial coefficient of positive n and k is given by − Syntax C(n, k) = n! / (k! * (n-k)!) where, n >= k Example of Binomial Coefficient Calculation For ...
Read MoreC Program for sum of cos(x) series
We are given with the value of x and n where, x is the angle for cos and n is the number of terms in the cos(x) series. The cosine series allows us to calculate cos(x) using polynomial approximation instead of built-in trigonometric functions. Cos(x) Function Cos(x) is a trigonometric function which calculates the cosine of an angle. It can be represented as an infinite series using Taylor expansion. Cosine Function Properties: • Range: [-1, 1] • Period: 2π radians (360°) • cos(0) = 1, cos(π/2) = 0 ...
Read MoreC Program for nth Catalan Number
Given an integer n, the task is to find the Catalan Number at the nth position. Catalan numbers are a sequence of natural numbers that occur in various counting problems in combinatorics and computer science. Catalan numbers C0, C1, C2, … Cn are defined by the formula − $$c_{n}=\frac{1}{n+1}\binom{2n}{n} = \frac{2n!}{(n+1)!n!}$$ The first few Catalan numbers for n = 0, 1, 2, 3, … are 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, … Syntax unsigned long int catalan(unsigned int n); Applications of Catalan Numbers Counting the number ...
Read MoreC Program that receives a number and prints it out in large size
In C, we can create a program that displays numbers in large size using ASCII art patterns made with hash symbols. This technique is useful for creating visually appealing banner-style output or digital displays. Syntax void printLargeNumber(char number[]); Approach The solution uses predefined character arrays to store ASCII art patterns for each digit (0-9). Each digit pattern is 7 rows high and 8 characters wide − Define 2D character arrays for each digit's visual pattern Traverse the input string character by character Print corresponding patterns row by row to display digits side ...
Read More