Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

CHECK IF SYSTEM IS LITTLE ENDIAN OR BIG ENDIAN IN C

Check System Endianness in C

✅ CHECK SYSTEM ENDIANNESS IN C

#include <stdio.h>

int main() {
    int x = 0x12AB6578;
    char *ptr = (char *)&x;

    if (*ptr == 0x78) {
        printf("System is Little Endian:\n");
    } else {
        printf("System is Big Endian:\n");
    }

    return 0;
}
    

🧠 Explanation:

This program determines the endianness of the system.

  • A hexadecimal number is stored in memory: 0x12AB6578.
  • The memory address of x is typecast to a char*, pointing to the least significant byte.
  • If the first byte contains 0x78, the system is Little Endian (least significant byte stored first).
  • Otherwise, the system is Big Endian.

πŸ–₯️ Sample Output:

System is Little Endian:
    

πŸ”‘ Keywords:

C program to check endianness, little endian vs big endian, pointer typecasting in C, memory representation in C, system architecture test.

Comments

Popular Posts

πŸŒ™