Write a c program to demonstrate Type casting in c?

Answers were Sorted based on User's Feedback



Write a c program to demonstrate Type casting in c?..

Answer / 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

Write a c program to demonstrate Type casting in c?..

Answer / pinkey

#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=4,c;
c=short(a+b);
printf("%d",c);
getch();
}

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More C Interview Questions

write a c program to print the values in words eg:- 143 written it has (one hundred and forty three)& 104, 114 are also written words

5 Answers   Captronic, DELL, Google, IBM, Mithi, RCC, Wipro,


What is an lvalue?

0 Answers  


Suggesting that there can be 62 seconds in a minute?

0 Answers  


difference between spiral and waterfall model

1 Answers  


Which node is more powerful and can handle local information processing or graphics processing?

0 Answers  






define c

6 Answers   HCL, TCS,


Can the curly brackets { } be used to enclose a single line of code?

0 Answers  


What is I ++ in c programming?

0 Answers  


When should a far pointer be used?

0 Answers   Aspire, Infogain,


If input is 123 then how to print 100 and 20 and 3 seperately?

4 Answers  


why array index always starts from zero??

4 Answers   TCS,


in b=6.6/a+(2*a+(3*c)/a*d)/(2/n); which operation will be performed first a) 6.6/a b) 2*a c) 3*c d) 2/n

1 Answers  


Categories