Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 183 of 377

Bash program to check if the Number is a Palindrome?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 4K+ Views

In C programming, to check whether a number is a palindrome, we need to reverse the number and compare it with the original. A palindrome number reads the same forwards and backwards, like 12321 or 1221. Syntax int reverseNumber(int num); int isPalindrome(int num); Method 1: Using Mathematical Approach This method extracts digits from the end and builds the reversed number mathematically − #include int reverseNumber(int num) { int reversed = 0; while (num != 0) { ...

Read More

Average of ASCII values of characters of a given string?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 942 Views

In C programming, calculating the average of ASCII values of characters in a string involves summing all character ASCII values and dividing by the string length. For example, the string "ABC" has ASCII values 65, 66, 67, giving an average of 66. Syntax float calculateAsciiAverage(char str[]); Algorithm asciiAverage(String) Begin sum := 0 for each character c in String, do sum := sum + ASCII of c done return sum/length of String End ...

Read More

Average of first n odd naturals numbers?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 323 Views

In this article, we will learn how to find the average of the first n odd natural numbers using C programming. The first n odd natural numbers are 1, 3, 5, 7, 9, ... and so on. To get the ith odd number, we can use the formula 2*i - 1 (where i starts from 1). Syntax float averageOddNumbers(int n); Algorithm Begin sum := 0 for i from 1 to n, do sum := sum + (2*i - 1) ...

Read More

ASCII NUL, ASCII 0 ('0') and Numeric literal 0?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 7K+ Views

In C programming, it's crucial to understand the difference between ASCII NUL, ASCII '0', and the numeric literal 0. These are three distinct values with different purposes and representations. Syntax char asciiNul = '\0'; // ASCII NUL (null terminator) int zero = 0; // Numeric literal 0 char zeroChar = '0'; // ASCII character '0' ASCII Values and Representations ASCII NUL ('\0') − Hexadecimal: 0x00, Decimal: 0 ASCII '0' character − Hexadecimal: ...

Read More

Arrange given numbers to form the biggest number?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 347 Views

Here we will see how to generate the biggest number by rearranging the given numbers. Suppose there are {45, 74, 23} given, the program will find the largest number, that is 744523. Each digit will not be rearranged individually, but the whole numbers will be placed optimally to form the largest possible number. To solve this problem, we use custom string comparison logic. The comparing function takes two numbers a and b, then concatenates them to form "ab" and "ba". Whichever concatenation gives the larger value determines the sorting order. Syntax int compare(const void *a, const ...

Read More

Argument Coercion in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

Argument coercion in C is a technique where the compiler automatically converts function arguments from one data type to another during function calls. This follows the argument promotion rule − lower data types can be implicitly converted to higher data types, but not vice versa. The reason is that converting higher data types to lower ones may result in data loss. Syntax return_type function_name(parameter_type param); // Arguments are automatically coerced to match parameter types Type Promotion Hierarchy The following SVG shows the implicit conversion hierarchy in C − ...

Read More

Area of triangle formed by the axes of co-ordinates and a given straight line?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 186 Views

In coordinate geometry, we can find the area of a triangle formed by the x-axis, y-axis, and a given straight line. When a straight line intersects both coordinate axes, it creates a triangle with the origin as one vertex. Syntax double calculateTriangleArea(double a, double b, double c); Mathematical Formula For a straight line with equation ax + by + c = 0, the intercept form is − x/(-c/a) + y/(-c/b) = 1 The x-intercept is -c/a and y-intercept is -c/b. The area of the triangle formed ...

Read More

What's the difference between sizeof and alignof?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 804 Views

In C, understanding the difference between sizeof and _Alignof operators is crucial for memory layout optimization. The sizeof operator returns the total size of a type in bytes, while _Alignof (introduced in C11) returns the alignment requirement of a type. Syntax sizeof(type) _Alignof(type) Key Differences The sizeof operator returns the total memory space occupied by a type, including any padding bytes added for alignment. The _Alignof operator returns the alignment boundary requirement − the address where the type should be placed for optimal access. Example: Basic Data Types For primitive data types, ...

Read More

Addition of two numbers without propagating Carry?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 584 Views

Addition of two numbers without propagating carry is a digit-wise addition where each position is added independently without carrying over to the next position. For example, adding 7583 and 9642 gives 1611125 (7+9=16, 5+6=11, 8+4=12, 3+2=5). Addition Without Carry Propagation 7 5 8 3 + 9 6 4 2 ...

Read More

C/C++ Program to Find reminder of array multiplication divided by n ?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 326 Views

Here we will see how to calculate the remainder of array multiplication after dividing the result by n. The array and the value of n are supplied by the user. Suppose the array is like {12, 35, 69, 74, 165, 54} so the multiplication will be (12 * 35 * 69 * 74 * 165 * 54) = 19107673200. Now if we want to get the remainder after dividing this by 47 it will be 14. As we can see this problem is very simple. We can easily multiply the elements then by using modulus operator, it can get ...

Read More
Showing 1821–1830 of 3,768 articles
« Prev 1 181 182 183 184 185 377 Next »
Advertisements