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 program to print largest number of each row of a 2D array

0 Answers  


What is void c?

0 Answers  


What does char * * argv mean in c?

0 Answers  


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

0 Answers  


Do pointers take up memory?

0 Answers  






write a c program to find largest number in matrix(in each row,each column, diagonally, and in the whole matrix)? Its urgent.

2 Answers  


Why isn't any of this standardized in c? Any real program has to do some of these things.

0 Answers  


Why do we use pointer to pointer in c?

0 Answers  


What do you mean by recursion in c?

0 Answers  


What is bubble sort in c?

0 Answers  


Can you explain the four storage classes in C?

0 Answers   TCS,


what is level of tree if leaf node is at level 4.please explain.

1 Answers   Wipro,


Categories