Write a c program to demonstrate Type casting in c?

Answer Posted / shivakumar

#include <stdio.h>

int main()
{
for ( int x = 0; x < 256; x++ ) {
/* Note the use of the int version of x to output a
number and the use
* of (char) to typecast the x into a character
which outputs the
* ASCII character that corresponds to the current
number
*/
printf( "%d = %c\n", x, (char)x );
}
getchar();

}

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how do you execute a c program in unix.

637


Dont ansi function prototypes render lint obsolete?

607


Explain what are preprocessor directives?

630


How many levels of pointers have?

596


How can I change the size of the dynamically allocated array?

634






What is the explanation for cyclic nature of data types in c?

648


What is meant by errors and debugging?

649


Is main is user defined function?

598


All technical questions

1512


What is typedf?

671


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2802


Explain how can I convert a number to a string?

650


What does the function toupper() do?

658


What is a void pointer in c?

609


What are the functions to open and close the file in c language?

596