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
Articles by Samual Sam
Page 5 of 151
Difference between CSS border-collapse:collapse; and border-collapse:separate;
The CSS border-collapse property controls how table borders are displayed. The key difference between collapse and separate is how adjacent cell borders are handled − collapse merges adjacent borders into a single border, while separate keeps each cell's borders distinct with gaps between them. Syntax table { border-collapse: collapse | separate; } Possible Values ValueDescription collapseAdjacent borders are merged into a single border separateEach cell maintains its own border with spacing between cells (default) Example: Comparing Border Collapse Values The following example demonstrates both values side ...
Read MoreUse of bool in C
In C, there is no predefined datatype as bool. However, we can create a boolean type using enum or use the standard header (C99 and later). With enum, we create a boolean type where false holds value 0 and true holds value 1. Syntax typedef enum { false, true } bool; // Or using C99 standard #include Method 1: Using Enum We can create a custom boolean type using typedef enum − #include typedef enum { false, true } bool; int main() { ...
Read MoreHow to write a running C code without main()?
In C programming, it is possible to write a program without the traditional main() function. While main() appears to be the entry point from a programmer's perspective, the system actually calls _start() first, which sets up the environment before calling main(). Syntax int _start() { // Program code here _exit(status_code); } Note: To compile programs without main(), use the -nostartfiles flag with gcc to skip the standard startup files that expect a main() function. Example Here's how to create a C program using ...
Read MoreHow to count set bits in a floating point number in C?
In this problem, one floating point value is given. We have to find the number of set bits in the binary representation of it. This involves analyzing the IEEE 754 single-precision floating point format used by C compilers. For example, if a floating point number is 0.15625, there are six set bits in its 32-bit binary representation. The IEEE 754 format consists of 1 sign bit, 8 exponent bits, and 23 mantissa bits. IEEE 754 Single Precision Format (32 bits) S ...
Read MoreHow will you show memory representation of C variables?
In C programming, understanding the memory representation of variables is crucial for debugging and low-level programming. This involves examining how different data types are stored in memory at the byte level. Syntax typedef unsigned char *byte_pointer; void display_bytes(byte_pointer ptr, int length); Algorithm To display memory representation of C variables, follow these steps − Get the address and size of the variable using & operator and sizeof() Typecast the address to unsigned char* to access individual bytes Loop through each byte and print its hexadecimal value Example: Memory Representation of Different ...
Read MoreImplicit return type int in C
In C, if a function is declared without an explicit return type, the compiler implicitly assumes the return type to be int. This behavior was allowed in older C standards (C89/C90) but is deprecated and not recommended. The C99 standard requires explicit return types for all functions. Syntax function_name(parameters) { /* Function body */ return value; /* Implicitly returns int */ } Example: Implicit Return Type Here's an example demonstrating implicit return type behavior − #include my_function(int x) { ...
Read MoreDifference between char s[] and char *s in C
In C programming, there are two common ways to declare strings: char s[] and char *s. While both can hold strings, they have fundamental differences in memory allocation, mutability, and behavior. Syntax char s[] = "string literal"; // Array declaration char *s = "string literal"; // Pointer declaration Key Differences Aspect char s[] char *s Type Array of characters Pointer to char Memory Location Stack (local array) Pointer on stack, string in read-only section Mutability Modifiable Read-only ...
Read MoreVariable length arguments for Macros in C
In C, we can use variable length arguments for macros, similar to how we use them with functions. This is achieved using ellipsis (…) and the special __VA_ARGS__ identifier. The concatenation operator ## is used to handle cases where no variable arguments are provided. Syntax #define MACRO_NAME(fixed_params, ...) macro_body __VA_ARGS__ Where __VA_ARGS__ represents all the variable arguments passed to the macro, and ## can be used for token pasting. Example: Logging Macro with Variable Arguments This example demonstrates a logging macro that accepts variable arguments like printf(). The macro prints the filename, line ...
Read MoreWhat is long long in C/C++?
In C programming, long long is an extended integer data type that provides a larger range for storing integer values than the standard long type. The long long type was introduced in C99 standard to handle very large integer values that exceed the capacity of regular int or long types. Syntax long long variable_name; long long int variable_name; // equivalent to above Size and Range The long long data type is guaranteed to be at least 64 bits (8 bytes) according to the C standard. The exact size may vary between systems, but it's ...
Read MoreDoes Ternary operation exist in MySQL just like C or C++?
Yes, ternary operation exists in MySQL using the CASE WHEN statement, which provides similar conditional logic to the ternary operator in C/C++. Let us first examine how the ternary operator works in C and then see its MySQL equivalent. Syntax C Ternary Operator: condition ? value_if_true : value_if_false MySQL Equivalent: CASE WHEN condition THEN value_if_true ELSE value_if_false END Example: C Ternary Operator Here is a complete C program demonstrating the ternary operator − #include int main() { int X = 5; ...
Read More