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

Explain what math functions are available for integers? For floating point?

833


Write the control statements in C language

853


Tell us bitwise shift operators?

791


When can a far pointer be used?

751


Differentiate between the expression “++a” and “a++”?

957


Which is the best website to learn c programming?

806


What’s the special use of UNIONS?

857


What the different types of arrays in c?

795


What is the use of volatile?

818


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

846


Is main a keyword in c?

822


Why do we need functions in c?

737


If fflush wont work, what can I use to flush input?

836


Where in memory are my variables stored?

826


What is the difference between NULL and NUL?

993