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
write a program to find out prime number using sieve case?
Do you know the difference between malloc() and calloc() function?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above
What is structure padding and packing in c?
What is declaration and definition in c?
Explain how can I manipulate strings of multibyte characters?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
Can you write the algorithm for Queue?
pierrot's divisor program using c or c++ code
What is a method in c?
What is the difference between typedef struct and struct?
What are the types of data files?
What are derived data types in c?
What is variable in c example?
Do you have any idea about the use of "auto" keyword?