#include <stdio.h> #include <conio.h> #include <math.h> void main() { float a, b, c; float root1, root2,de,d; printf("enter the values of a, b and c"); scanf("%f%f%f", &a,&b,&c); de=(b*b)-4*(a*c); d=sqrt(de); root1=(-b+d) /(2.0*a); root2=(-b-d) /(2.0*a); printf(" roots of the equation are %f %f", root1,root2); getch(); }
Parameters are the formal arguments of a function, as defined by the function. When you pass arguments to a function, those arguments are assigned to the function's parameters, either by value or by reference, depending on how the parameters are declared in the function. The following example explains both: void foo( int param ) { // param is a by value parameter, which is a copy of the argument passed to it. } void bar( int& param ) { // param is a reference parameter, which references the argument passed to it. } int main() { int arg = 100; foo( arg ); bar( arg ); return( 0 ); } Note that passing a pointer is the same as passing an int by value: the pointer's value is passed to the function, not the pointer itself. To pass a pointer by reference, you must pass a pointer to pointer and the function's parameter must accept a pointer to pointer.
// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);
Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer
Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;
void is type of pointer that usually means that you can make it point to any data type. When you make a pointer point to somewhere its data type should match with the place where you want it to point. When you dont know the data type where it will point to then you can declare a void pointer and make it point to the data type it want.
Parameters are the formal arguments of a function, as defined by the function. When you pass arguments to a function, those arguments are assigned to the function's parameters, either by value or by reference, depending on how the parameters are declared in the function. The following example explains both: void foo( int param ) { // param is a by value parameter, which is a copy of the argument passed to it. } void bar( int& param ) { // param is a reference parameter, which references the argument passed to it. } int main() { int arg = 100; foo( arg ); bar( arg ); return( 0 ); } Note that passing a pointer is the same as passing an int by value: the pointer's value is passed to the function, not the pointer itself. To pass a pointer by reference, you must pass a pointer to pointer and the function's parameter must accept a pointer to pointer.
When a variable is passed by value, the function receives a copy of the variable. When a variable is passed by reference, the function receives a reference, or pointer, to the original data.
// declare a function int* function(int, int); or int* (function)(int, int); // declare a pointer to a function int* (*pointer_to_function)(int, int);
You don't use 'VOID', but 'void'. It means different things, such as:- void as function type means no return value- void as function parameter means no parameters- 'void *' as pointer-types means generic pointer
Overloading refers to defining multiple functions of the same name with different numbers/types of parameters. So no, you cannot overload a pointer.
The this operator is not a c operator. It is a c++ keyword. It is equivalent to an r-value pointer to the current instance of an object. It is useful when resolving between object members and method parameters.
No. Function parameters are passed by value. Always. Even the so called "call by reference" is a value - the value of the pointer or the address of the object - but what is placed in the parameter list is a value.
1. pointer to a constant means you can not change what the pointer points to 2. constant pointer means you can not change the pointer.
Example: int x; -- integer int *px= &x; -- pointer to integer int **ppx= &px; -- pointer to pointer to integer int ***pppx= &ppx; -- pointer to pointer to pointer to integer
A pointer only holds an address information (location) in the memory. if a pointer holds points another pointer then it is a pointer to an other pointer. Pointer holds an address in the memory so in that address there is an other location information that shows another location.
pointer is the variable that holds the address of another variable
It is not possible to determine the width of the cell with just the length of the pointer provided. The width of the cell would depend on its specific shape and dimensions, which would require more information to calculate.