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
What is memory leak in c?
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
Explain how do I determine whether a character is numeric, alphabetic, and so on?
How many levels of indirection in pointers can you have in a single declaration?
Difference between Shallow copy and Deep copy?
Is stack a keyword in c?
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What are the types of type qualifiers in c?
Explain what is the difference between null and nul?
Does c have class?
What is bash c?
How to explain the final year project as a fresher please answer with sample project
a value that does not change during program execution a) variabe b) argument c) parameter d) none
What is the difference between scanf and fscanf?