You can't address memory with floating point values. All pointers are integer values pointing to a location in memory, regardless of what type it is pointing to. If you wanted a floating point pointer, then the following should do the trick:
float *floatingPointer;
Note: If you wanted to ask that which integer type is big enough to hold a (flat) pointer, then the answer: ptrdiff_t, intptr_t (both signed) and size_t, uintptr_t (both unsigned).
Yes, an integer can be assigned as a float value.But it get stored as a float value, that is an implicit type conversion occurs during compilation.Smaller data types are convertible to larger data types.eg:float b=12;// an integer constant is assigned to a float variableprintf("%f",b);// when printing b it will print as 12.000000
there r 3 types of variable in 'C' Integer Float Character
The main advantages of using pointers are 1.) Function cannot return more than one value. But when the same function can modify many pointer variables and function as if it is returning more than one variable. 2.) In the case of arrays, we can decide the size of the array at runtime by allocating the necessary space. C has a minimum number of fundamental data types - a single character, a single integer or float, and a few derived data types such as a structure, an enumerated list, and an array. If you want to do much more than that, you make use of pointers. Pointers allow you to dynamically request memory to store off information for use later. They allow you to create linked lists and other algorithmically oriented data structures.
No. The address of a float can only be assigned to a variable of type pointer to float. Any other (coerced) use is outside of the definition, implementation, and portability of the language.Yes, with typecast, but it is entirely pointless:float f;char c = (char)&f;
A pointer variable is a variable that contains the memory location of another variable or an array (or anything else in memory). Effectively, it points to another memory location. For standard variables, you define a type, assign a value to that variable or read the value from it, and you can also read the memory location (&n = memory location of n) of the variable. For pointers, you can point them to any variable, even another pointer, and you can get the value of the variable it points to (*p), the location of that variable in memory (p), or the address in memory of the pointer itself (&p). Consider: long n = 65; long *p; p = &n; Results: Type | Name | Location | Value long n 0xA3FF 65 long * p 0x31DF 0xA3FF So p points to n. Now, n = 65 &n = 0xA3FF p = 0xA3FF *p = 65 &p = 0x31DF You may find yourself having to use typecasts frequently when using pointers. Pointers are useful when passing data to functions. For instance, consider the following function: void add(int a, int b, int c) { c = a + b; } The problem here is that the computer copies each variable into a new memory location before passing them to the function as local variables. This function effectively does nothing. However, if you change the function to: void add(int a, int b, int *c) { c = a + b; } and call the function by passing in the location of the variable to the function: add(a,b,&c); then you can modify the variable itself. Pointers are also good for working with arrays: char *c = "Hello World"; int i=0; while (c[i] != 0x00) { cout << c[i]; c++ } //print one letter at a time.
If it contains a decimal point or an exponential part, then it should be handled as a float (or double).You can determine an existing variable's type in C using the type() function
Integer numbers : ...-5,-4,-3,-2,-1,0,1,2,3,4,5... Float numbers 1.25, 1.26 etc They are float numbers because its value can be altered after the point, which is based on an integer number.
You can do this by creating a forwarddeclaration of the function. You can call the forward drclared function inside the main to use it.int result(float num1, float num2);intmain(void){int value = result(3.14, 2.74);return (0);}intresult(float num1, float num2){int value = 0;// function codes goes here// you can alter the value of variable 'value'return (value);}The returning value of the 'result()' function is assigned to variable 'value' in 'main()'.
Constants are defines using the final keyword.Variables are defined using the one of the keywords:charbooleanintdoublelongintStringTo use a constant you would have to put in something likedouble final pi = 3.14;
Some of them are: 1. char, short, int, long, float, double 2. pointers to these 3. arrays of these 4. arrays of pointers 5. pointers to arrays ...
When assigning a literal value, such as 5.628, to a float variable, you can avoid the decimal truncation warning by either using the float form of the constant (float var = 5.628f), typecasting the assignment (float var = (float) 5.628), or by making the variable double (double var = 5.628).
A float variable can store both positive and negative numbers.