How do I print the type of variable in c?

How do I print the type of variable in c

To print the type of variable in C, you can use the printf() function with a format specifier %s to print a string that represents the type of the variable. The typeof operator in C can be used to get the type of a variable at runtime. Here is an example:

#include <stdio.h>

int main() {
    int num = 10;
    float f = 3.14;
    double d = 2.71828;
    char c = 'A';
    
    printf("Type of num is %s\n", typeof(num));
    printf("Type of f is %s\n", typeof(f));
    printf("Type of d is %s\n", typeof(d));
    printf("Type of c is %s\n", typeof(c));

    return 0;
}

  1. How can I compare int to char in C?

    To compare an int to a char in C, you can use the ASCII values of the characters. In C, characters are represented as integer values based on the ASCII encoding scheme.
    Here’s an example that compares an int to a char using their ASCII values:
    see more

C programming examples

Github

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck