C Articles

Page 23 of 96

What are the scope rules to functions in C programming?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 703 Views

Scope rules in C programming define where variables and functions can be accessed within a program. These rules determine the visibility and lifetime of variables based on where they are declared. Syntax /* Global scope */ data_type variable_name; function_name() { /* Local scope */ data_type variable_name; } Local Scope Local scope specifies that variables defined within a block are visible only in that block and invisible outside the block. These variables exist only during the function execution. Global Scope Global scope specifies that ...

Read More

What are the different types of functions in C Programming?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 14K+ Views

Functions in C programming are broadly classified into two types which are as follows − Predefined functions User-defined functions Predefined (or) Library Functions Predefined functions are already defined in the system libraries. These functions allow programmers to reuse existing code, which helps write error-free programs efficiently. The user must be aware of the syntax and header file required for each function. These functions are pre-written and tested by system developers They are available in standard library header files like stdio.h, math.h, string.h Programmer needs to include the appropriate header file to use them ...

Read More

How to write a C program to find the roots of a quadratic equation?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 156K+ Views

A quadratic equation is of the form ax² + bx + c = 0, where a, b, and c are coefficients and a ≠ 0. The roots can be found using the quadratic formula, and the nature of roots depends on the discriminant value. Syntax r1 = (-b + sqrt(discriminant)) / (2 * a); r2 = (-b - sqrt(discriminant)) / (2 * a); Mathematical Formula The quadratic formula is − r₁ = (-b + √(b² - 4ac)) / (2a) r₂ = (-b - √(b² - 4ac)) / (2a) Where the discriminant (d) ...

Read More

Convert vowels from upper to lower or lower to upper using C program

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, we can convert vowels in a string from uppercase to lowercase or lowercase to uppercase using character manipulation functions. This involves checking each character to identify vowels and then applying the appropriate case conversion. Syntax #include int toupper(int c); // Converts to uppercase int tolower(int c); // Converts to lowercase Method 1: Convert Lowercase Vowels to Uppercase This approach converts all lowercase vowels (a, e, i, o, u) to their uppercase equivalents while keeping other characters unchanged − #include #include ...

Read More

C Program to find the given number is strong or not

Sindhura Repala
Sindhura Repala
Updated on 15-Mar-2026 44K+ Views

A strong number is a number where the sum of the factorial of its digits equals the number itself. For example, 145 is a strong number because 1! + 4! + 5! = 1 + 24 + 120 = 145. Syntax int factorial(int n); int isStrongNumber(int num); Understanding Strong Numbers Let's examine some examples to understand the concept better − 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145 (Strong number) 123 = 1! + 2! + ...

Read More

C Program to find two's complement for a given number

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 18K+ Views

The two's complement is a mathematical operation used to represent negative numbers in binary form. It can be calculated using two methods − Method 1 − Convert the given binary number into one's complement and then add 1. Method 2 − Starting from the rightmost bit, copy all bits until the first '1' (including it), then complement all remaining bits. Syntax // One's complement: flip all bits // Two's complement: one's complement + 1 How Two's Complement Works The two's complement process involves these steps − Find the one's ...

Read More

What is enumerated data type in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 3K+ Views

An enumerated data type in C is a user-defined data type that allows programmers to create variables with a restricted set of named values. It provides a way to assign names to integer constants, making code more readable and maintainable. The keyword is enum. Syntax enum tagname { identifier1, identifier2, ..., identifier_n }; Basic Example Here's how to declare an enumeration for days of the week − enum week { mon, tue, wed, thu, fri, sat, sun }; By default, identifier ...

Read More

C Program to delete the duplicate elements in an array

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 55K+ Views

In C programming, removing duplicate elements from an array means creating a new array that contains only unique elements. This is a common array manipulation task that helps eliminate redundancy in data. Syntax for(i = 0; i < size; i++) { for(j = i + 1; j < size; j++) { if(arr[i] == arr[j]) { // Shift elements left to remove duplicate ...

Read More

C Program to count trailing and leading zeros in a binary number

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 3K+ Views

In C programming, counting trailing and leading zeros in a binary representation of a number is a common bit manipulation task. Trailing zeros are the consecutive zeros from the least significant bit (LSB) until the first set bit, while leading zeros are the consecutive zeros from the most significant bit (MSB) until the first set bit. Syntax /* For trailing zeros */ int countTrailingZeros(int number); /* For leading zeros */ int countLeadingZeros(int number); Trailing Zeros Trailing zeros are the zeros that appear after the rightmost set bit (1) when counting from ...

Read More

C program to rotate the bits for a given number

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 3K+ Views

Bit rotation is a fundamental bitwise operation where bits in a number are shifted circularly. In left rotation, bits move left and the leftmost bit wraps to the rightmost position. In right rotation, bits move right and the rightmost bit wraps to the leftmost position. Syntax // Left rotation int leftRotate(int num, int rotations); // Right rotation int rightRotate(int num, int rotations); Key Concepts Left rotation: Bits are shifted left, MSB wraps to LSB position Right rotation: Bits are shifted right, LSB wraps to MSB position Circular shift: No bits ...

Read More
Showing 221–230 of 953 articles
« Prev 1 21 22 23 24 25 96 Next »
Advertisements