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
C Articles
Page 49 of 96
Deep Copy of Struct Member Arrays in C
In C, when you assign one structure variable to another, a shallow copy is typically performed. However, there is an important exception: if a structure member is an array, the compiler automatically performs a deep copy of that array. This means the array contents are copied element by element, creating independent copies in memory. Syntax struct_type destination = source; // Assignment copies all members Example: Deep Copy of Array Members The following example demonstrates how array members within structures are deep copied automatically − #include #include typedef struct ...
Read MoreC Program for Armstrong Numbers
An Armstrong number (also known as narcissistic number) is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1³ + 5³ + 3³ = 1 + 125 + 27 = 153. Syntax int armstrong(int number); Formula For an n-digit number with digits d₁, d₂, ..., dₙ − Armstrong Number = d₁ⁿ + d₂ⁿ + ... + dₙⁿ Example: 153 (3-digit number) 1³ + 5³ + ...
Read MoreC Program for Area And Perimeter Of Rectangle
Given a length and breadth of a rectangle we have to find its area and perimeter. Rectangle is a 2-D figure containing four sides and four angles of 90 degrees each. All the sides of rectangle are not equal − only the opposite sides of a rectangle are equal. The diagonals in a rectangle also are of the same length. Syntax Area = Length × Breadth Perimeter = 2 × (Length + Breadth) Algorithm Length Breadth ...
Read MoreC Program for n-th odd number
Given a number N, we have to find the N-th odd number. Odd numbers are the numbers which are not completely divisible by 2 and their remainder is not zero, like 1, 3, 5, 7, 9, etc. If we closely observe the sequence of odd numbers, we can represent them mathematically as − 1st odd number: (2*1)-1 = 1 2nd odd number: (2*2)-1 = 3 3rd odd number: (2*3)-1 = 5 4th odd number: (2*4)-1 = 7 ... Nth odd number: (2*N)-1 So, to solve the problem we can simply multiply the number ...
Read MoreC Program for n-th even number
Given a number N we have to find the N-th even number. Even numbers are the numbers which are completely divided by 2 and their remainder is zero. Like 2, 4, 6, 8, 10, and so on. If we closely observe the list of even numbers we can also represent them as − 2*1=2, 2*2=4, 2*3=6, 2*4=8, ….2*N. So, to solve the problem we can simply multiply the number N with 2, so the result will be the number which is divisible by 2, i.e. the even number. Syntax nth_even_number = n * ...
Read MoreProgram to Convert Radian to Degree in C
Converting radians to degrees is a common mathematical operation in C programming. A radian is the standard unit for measuring angles in mathematics, while degrees are commonly used in everyday applications. The complete angle of a circle is 360 degrees or 2π radians. Syntax degree = radian × (180 / π) Where π (pi) ≈ 3.14159 or can be approximated as 22/7. Conversion Formula The mathematical relationship between radians and degrees is − degree = radian × (180/π) where, π = 3.14159 For example, if radian = 9.0, then ...
Read MoreC Program to Minimum and Maximum prime numbers in an array
In C programming, finding the minimum and maximum prime numbers in an array requires two key steps: identifying prime numbers efficiently and tracking the smallest and largest primes found. This problem uses the Sieve of Eratosthenes algorithm for efficient prime number generation. Problem Statement Given an array of n positive integers, we need to find the prime numbers with minimum and maximum values. If the given array is − arr[] = {10, 4, 1, 12, 13, 7, 6, 2, 27, 33} then minimum prime number is 2 and maximum prime number is 13 ...
Read MoreProgram for Identity Matrix in C
Given a square matrix M[r][c] where 'r' is some number of rows and 'c' are columns such that r = c, we have to check that 'M' is identity matrix or not. Identity Matrix Identity matrix is also known as Unit matrix of size nxn square matrix where diagonal elements will only have integer value one and non diagonal elements will only have integer value as 0. Like in the given Example below − I₁ = [1] I₂ = ...
Read MoreProgram to Convert Centimeter to Feet and Inches in C
Given with the length in centimeters as an input, the task is to convert the given length into feet and inches using C programming. We can use length conversion formulas for this − 1 feet = 30.48 cm 1 inch = 2.54 cm Syntax double inches = centimeters * 0.3937; double feet = centimeters * 0.0328; Algorithm Start Step 1 → Declare function to perform conversion double convert(int centimeter) set double inch = 0.3937 * centimeter ...
Read MoreProgram to Calculate the Perimeter of a Decagon in C program
A decagon is a polygon with 10 sides and 10 vertices. In a regular decagon, all sides are equal in length and each internal angle measures 144 degrees. The perimeter of any polygon is the sum of all its side lengths. V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 ...
Read More