Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

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

πŸŒ™