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


Please Help Members By Posting Answers For Below Questions

What is memory leak in c?

629


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.

2643


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

2528


Explain how do I determine whether a character is numeric, alphabetic, and so on?

647


How many levels of indirection in pointers can you have in a single declaration?

587






Difference between Shallow copy and Deep copy?

1563


Is stack a keyword in c?

630


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7385


What are the types of type qualifiers in c?

642


Explain what is the difference between null and nul?

646


Does c have class?

608


What is bash c?

550


How to explain the final year project as a fresher please answer with sample project

463


a value that does not change during program execution a) variabe b) argument c) parameter d) none

688


What is the difference between scanf and fscanf?

656