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

actually i have 2 years teaching experience as computer faculty but now i am a DBA but when i go for interview many peoples asked me why i left my teaching profession and why i want to come in this field kindly give me the proper answer of this queston

3 Answers   Ramco,


How will you allocate memory to double a pointer?

1 Answers  


What is the value of h?

0 Answers  


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

0 Answers   Huawei,


related proverb of "dont count your chicken before it hatches"

1 Answers  






which is the best site or book for learning C...and i need the content for C..how to get the good programming skills....? can plz suggest me....

2 Answers  


Lists the benefits of c programming language?

0 Answers  


What is logical error?

0 Answers  


How the processor registers can be used in C ?

7 Answers   HP,


hat is a pointer?

4 Answers   Assurgent,


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

0 Answers   RBI,


Explain what are the advantages and disadvantages of a heap?

0 Answers  


Categories