1,967 views

3 Answers

1 votes
1 votes
Option b

because conversion of float to pointer type is not allowed in C.
0 votes
0 votes

Answer is : B from float to char pointer 

Casting pointers is usually invalid in C.because,

A pointer is an arrow that points to an address in memory, with a label indicating the type of the value. The label refers to indicating the type of value. For example, it is equivalent to specifying if it’s a house or a clothing store. The address indicates where to look and the type indicates what to take. Casting the pointer changes the label on the arrow but not where the arrow points. This means that even if we change the label from a house to a clothing store, it will not actually change the reality of the thing at that address.

let’s see what pointer casting actually means in the context of programming,

For example, if float * were inherently 4-byte aligned, casting ‘char *’ to ‘float *’ would lose the lower bits. Also, in general, it’s forbidden to access an object except via an lvalue of the correct type for the object. There are some exceptions, but unless you understand them very well, you don’t want to do it. One thing to note is that aliasing(aliasing refers to the situation where the same memory location can be accessed by using different names.) is only a problem if you actually dereference the pointer i.e. apply the * or -> operators to it, or pass it to a function that will dereference it.

Related questions

0 votes
0 votes
1 answer
1
2 votes
2 votes
2 answers
3
atulcse asked Jan 15, 2022
662 views
Consider the following programint find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; ...
0 votes
0 votes
3 answers
4
ramakrushna asked Dec 23, 2021
695 views
What should be the ans. Isn’t the Function initialization should be outside main function? They are given inside main. If declaration would be outside main then ans sho...