what would be the output of the following program?
main()
{
int k = 123;
char *ptr;
ptr = &k;
printf("%d",*ptr);
}
Answer Posted / vadivelt
Hi Srsabariselvan,
If you are not very clear on the answer, please avoid to post
it. Because your answer seems to be misguiding the persons
who are very new to this question(probly pointers).
Who said that a pointer has to hold the address of same
datatype????.... a pointer of any datatype can hold the
address of any other data types(only it is enough to have
proper typecasting).
There will not be a compilation error. But most of the time
loss of data may be there(ie., when a bigger size of
datatype is typecasted to smaller eg: int* is typecasted to
char*). Please read the answer #1 for clear understanding.
Still if you are not clear on the concept, Copy the code
and execute it in ur compiler and analys the output.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Write a program to check prime number in c programming?
What is meant by int main ()?
For what purpose null pointer used?
What is the use of a static variable in c?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
What are the scope of static variables?
What is union and structure in c?
Can we replace the struct function in tree syntax with a union?
What is data structure in c and its types?
Is null always defined as 0(zero)?
Why pointers are used in c?
What is %d called in c?
Explain how are portions of a program disabled in demo versions?
What is gets() function?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)