Write a C program to demonstrate typedef

0

Here's an example program that demonstrates the use of typedef in C:


In this program, we use typedef to define a new type Number that is equivalent to the built-in int type. Then, in the main function, we declare a variable x of type Number and initialize it to the value 42. Finally, we print the value of x using printf.

When we compile and run this program, it should output:

x = 42

This shows that typedef can be used to create an alias for an existing type, which can make our code more readable and easier to understand.

Post a Comment

0Comments
Post a Comment (0)