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 22 of 96
Explain the Format of C language
C programming is a general-purpose, procedural, imperative computer programming language developed by Dennis Ritchie at Bell Labs in the early 1970s. The C language follows a specific format and syntax rules that must be adhered to for successful compilation and execution. Key Formatting Rules in C The C programming language follows these essential formatting conventions − Statements are terminated with semicolons (;) C is case sensitive Indentation is ignored by the compiler but improves readability Strings are placed in double quotes ("") Library functions and keywords are lowercase Newlines are handled via escape sequence ...
Read MoreCheck if the value entered is palindrome or not using C language
A palindrome is a number, word, or sequence of characters that reads the same backward as forward. For example, 121, 1331, and 12321 are palindromic numbers. To check if a number is a palindrome in C, we reverse the number and compare it with the original. If both are equal, the number is a palindrome. Syntax while (n > 0) { remainder = n % 10; reversed = (reversed * 10) + remainder; n = n / 10; } Algorithm The ...
Read MoreExplain the Random accessing files in C language
Random access in C allows you to move the file pointer to any position within a file, enabling non-sequential reading and writing operations. This is accomplished using three key functions that control file pointer positioning. Syntax long ftell(FILE *stream); void rewind(FILE *stream); int fseek(FILE *stream, long offset, int whence); ftell() Function The ftell() function returns the current position of the file pointer as a long integer representing the byte offset from the beginning of the file. #include int main() { FILE *fp; ...
Read MoreWhat are the high level I/O functions in C language?
High-level I/O functions in C provide an abstracted, user-friendly interface for input and output operations. These functions are part of the standard C library and offer better portability compared to low-level I/O functions. High Level vs Low Level I/O High Level I/O Easy to understand and use by programmers Portable across different systems Built-in buffering for better performance Low Level I/O Closer to the operating system Faster execution time System-dependent (non-portable) High Level I/O Functions The high level input-output (I/O) functions are explained below − Function Description ...
Read MoreGive the clarity on Pointer structures with suitable example in C language
Pointer to structure holds the address of an entire structure. Mainly, these are used to create complex data structures such as linked lists, trees, graphs and so on. The members of the structure can be accessed by using a special operator called arrow operator ( -> ). Syntax struct tagname *ptr; For example: struct student *s; Accessing Structure Members You can access pointer to structure members using the arrow operator − ptr->membername; For example: s->sno, s->sname, s->marks Example The following C program demonstrates ...
Read MoreHow to pass the address of structure as an argument to function in C language?
Passing the address of a structure as an argument to a function allows the function to access and modify the original structure through a pointer. This technique is memory-efficient and enables direct manipulation of structure members. Syntax return_type function_name(struct structure_name *pointer_variable); Key Points The address of the structure is passed as an argument to the function. It is collected in a pointer to structure in function header. Advantages No wastage of memory as there is no need of creating a copy again No need of returning the values back ...
Read MoreHow to pass individual members of structure as arguments to function in C language?
In C programming, you can pass individual members of a structure as arguments to functions. This approach treats each structure member as a separate parameter, allowing functions to work with specific data fields independently. Syntax functionName(structure_variable.member1, structure_variable.member2, ...); Key Points Each member is passed as an individual argument in the function call Structure members are collected as ordinary variables in the function header This method passes values by copy, not by reference Example: Calculating Student Total Marks Here's how to pass individual structure members to calculate total marks for students ...
Read MoreExplain string library functions with suitable examples in C
The C standard library provides several predefined functions for string manipulation in the string.h header file. These functions help perform operations like copying, comparing, concatenating, and searching strings efficiently. Common String Functions strlen() − finds string length strcpy() − copies strings strcat() − concatenates strings strcmp() − compares strings strstr() − searches for substrings The strlen() Function The strlen() function returns the number of characters in a string, excluding the null terminator. Syntax size_t strlen(const char *str); Example #include #include int main() { ...
Read MoreHow to create a pointer for strings using C language?
In C programming, you can create pointers to strings using arrays of pointers. An array of pointers to strings is an array where each element is a pointer that holds the base address of a string literal or character array. Syntax char *array_name[size] = {"string1", "string2", "string3", ...}; Here, each element array_name[i] is a pointer to the base address of the corresponding string. char *names[3] = {"Alice", "Bob", "Charlie"}; names[0] names[1] ...
Read MoreHow to pass individual elements in an array as argument to function in C language?
In C programming, you can pass individual array elements as arguments to functions by specifying the array element with its index in the function call. The function receives these elements as separate parameters, not as an array. Syntax functionName(array[index1], array[index2], ...); Example 1: Passing First and Last Elements This example demonstrates how to pass the first and last elements of an array to a function − #include void display(int first, int last) { printf("First element = %d", first); printf("Last element = %d", ...
Read More