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
What is a function simple definition?
Can two or more operators such as and be combined in a single line of program code?
What is const keyword in c?
Why is %d used in c?
List out few of the applications that make use of Multilinked Structures?
What is the right type to use for boolean values in c? Is there a standard type?
When should a type cast not be used?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
write a c program to find the sum of five entered numbers using an array named number
Explain pointers in c programming?
What is the right type to use for boolean values in c?
why wipro wase
how to build a exercise findig min number of e heap with list imlemented?
swap 2 numbers without using third variable?
develop algorithms to add polynomials (i) in one variable