what would be the output of the following program?
main()
{
int k = 123;
char *ptr;
ptr = &k;
printf("%d",*ptr);
}

Answer Posted / vadivelt

Output would be 123.

Since, the character pointer can hold the values
0 - 255(if it is unsigned) or -128 to 127 (if it is signed), we
will get value of k as result.

But if the k value is k > 255 and the pointer is unsigned,
or if the k value is k > -129 and k < 128 and the pointer
is signed then only lower 1 byte of k would be the result.
Remaining data will be lost.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a function simple definition?

608


Can two or more operators such as and be combined in a single line of program code?

801


What is const keyword in c?

739


Why is %d used in c?

559


List out few of the applications that make use of Multilinked Structures?

1284






What is the right type to use for boolean values in c? Is there a standard type?

557


When should a type cast not be used?

621


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

560


write a c program to find the sum of five entered numbers using an array named number

1617


Explain pointers in c programming?

628


What is the right type to use for boolean values in c?

580


why wipro wase

1822


how to build a exercise findig min number of e heap with list imlemented?

1601


swap 2 numbers without using third variable?

656


develop algorithms to add polynomials (i) in one variable

1732