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 enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.

1 Answers  


What is the most efficient way to store flag values?

0 Answers  


Explain how can I right-justify a string?

0 Answers  


what is the height of tree if leaf node is at level 3. please explain

0 Answers  


what is the other ways to find a logic to print whether a number is an even or odd wit out using % symbol??????? i know three different ways to print it. so i need any other different logic>>>>>

5 Answers   TCS,


What is the difference between a free-standing and a hosted environment?

0 Answers   Aspire,


what is the difference between c and java?

1 Answers  


what are the various memory handling mechanisms in C ?

4 Answers   HP,


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

0 Answers  


write a programme to convert temperature from farenheit to celcius?

4 Answers   IBM,


#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

6 Answers   ME,


How to establish connection with oracle database software from c language?

0 Answers  


Categories