C Articles

Page 28 of 96

Explain the variable declaration, initialization and assignment in C language

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

In C programming, variables are named storage locations in memory that hold data values. Unlike constants, variables can have their values modified during program execution. Before using any variable, it must be declared to inform the compiler about its data type and name. Syntax data_type variable_name; data_type variable_name = initial_value; data_type var1, var2, var3; Variable Declaration Variable declaration tells the compiler to reserve memory space for a variable with a specific data type. The syntax is − type variable_name; or for multiple variables of the same type − ...

Read More

Accessing variables of Int and Float without initializing in C

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

When we declare variables in C without initializing them, their values are unpredictable. This article demonstrates what happens when we try to access uninitialized int and float variables and explains the underlying memory behavior. Syntax data_type variable_name; // Declaration without initialization Understanding Uninitialized Variables When a variable is declared but not initialized, the following occurs − Memory is allocated for the variable during declaration The memory location contains whatever data was previously stored there This results in garbage values − unpredictable leftover data from previous program executions The actual ...

Read More

Given an example of C pointer addition and subtraction

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

Pointer arithmetic is a fundamental concept in C programming that allows you to perform mathematical operations on pointer variables. Two important operations are pointer addition and subtraction, which help navigate through memory addresses. Syntax /* Pointer Addition */ new_address = current_address + n; /* Pointer Subtraction */ new_address = current_address - n; Where n is the number of elements to move, and the actual byte offset is calculated as: n * sizeof(data_type) C Pointer Addition Pointer addition involves adding an integer value to a pointer. The result is a new memory address ...

Read More

Compute sum of all elements in 2 D array in C

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

In C programming, computing the sum of all elements in a 2D array involves traversing through each element using nested loops and accumulating the values. This is a fundamental operation when working with matrices and tabular data. Syntax datatype array_name[rows][columns]; For example: int arr[3][4]; creates a 2D array with 3 rows and 4 columns, containing 12 elements total. Example 1: Sum of All Elements Following is the C program to calculate the sum of all elements in a 2D array − #include int main() { ...

Read More

Explain volatile and restrict type qualifiers in C with an example

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

Type qualifiers in C add special attributes to existing data types to control how variables are accessed and optimized by the compiler. The two important type qualifiers are volatile and restrict, which help with memory management and compiler optimization. volatile Prevents compiler optimizations restrict Enables compiler optimizations const Read-only qualifier Type Qualifiers in C Syntax volatile ...

Read More

What are the C library functions?

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

Library functions are built-in functions that are grouped together and placed in a common location called library. Each function performs a specific operation, allowing us to get pre-defined outputs without implementing complex logic from scratch. All C standard library functions are declared by using many header files. These library functions are created at the time of designing the compilers. We include the header files in our C program by using #include. Whenever the program is compiled and executed, the related files are included in the C program. Syntax #include int main() { ...

Read More

What are the limitations of array in C language?

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

Arrays are a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Syntax data_type array_name[array_size]; Limitations of Arrays in C The limitations of an array are explained below − Homogeneous Data: An array which is formed will be homogeneous. That is, in an integer array only integer values can be stored, while in a ...

Read More

Explain top-down design and structure chart of function in C language

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

A function is a self-contained block that carries out a specific well defined task. Functions are fundamental building blocks in C programming that enable modular programming and code organization. Advantages of functions in C language include − Reusability − Functions can be called multiple times from different parts of the program. Reduced program length − Eliminates code duplication by defining common tasks once. Easy debugging − It is easy to locate and find any faulty function. Modular programming − It facilitates top-down modular programming approach. Top-Down Design Top-down design is a problem-solving methodology in ...

Read More

How floats are stored in C compiler?

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

In C programming language, float is a short term for floating point. Understanding how floats are stored internally helps developers work with precision and memory optimization effectively. IEEE 754 Standard Floating point numbers are represented using the IEEE 754 standard format, which consists of three components − Sign bit: 1 bit that denotes the sign (0 for positive, 1 for negative) Exponent: 8 bits for float (11 bits for double) stored with a bias Mantissa (Significand): 23 bits for float (52 bits for double) Syntax float variable_name = value; // IEEE 754 ...

Read More

What are primary data types in C language?

Aishwarya Naglot
Aishwarya Naglot
Updated on 15-Mar-2026 11K+ Views

Primary data types, also known as fundamental data types, are built-in data types in C programming language. The C compiler supports four fundamental data types that serve as the building blocks for storing and working with different kinds of data − Integer − for whole numbers Character − for single characters Float − for decimal numbers Double − for high-precision decimal numbers Syntax // Declaration syntax for primary data types int variable_name; char variable_name; float variable_name; double variable_name; Integer Data Type Integer data types store whole numbers (positive or negative) without ...

Read More
Showing 271–280 of 953 articles
« Prev 1 26 27 28 29 30 96 Next »
Advertisements