what is the definition of the the following in C brief defi

what is the definition of the the following in C++ ? (brief definition)

1- Argument

2- Pointer

3- Variable

4- Data type

Solution

Argument: Arguments are values that can be passed to a function so that they can used as input. The function has the below format:

<return type> functionName (arguments to the function)
{
   //what the function does
   return <value>;
}

The arguments to a function are passed by the caller function.
For example,

void samplefun(int x,int y)
{
   //to do
}

The above function is called from main() or someother function by passing the values for x and y, here x and y are the arguments for the function samplefun. The function is called as

samplefun(10,5);

When samplefun is called with arguments 10,5, samplefun creates parameters x and y and assigns values 10 and 5 respectively. x anf y are local to samplefun and are destroyed when the function terminates. Passing arguments to a function can be pass by value( passing the value of a variable), pass by reference (sending the reference of the variable) and pass by address(passing the address of the variable).


Pointer: A pointer is variable that holds the address of another variable as its value. As we know a variable is a name given to the memory location. The address of a variable can be accessed using the symbol \'&\' i.e., if x is a variable the &x gives us the address of x, Now a pointer is used to hold this address. Pointer can be declared using the below syntax,

type *pointername;

The declaration of a pointer variable is similar to a normal variable declaration but the only thing is variable name is preceeded by *.

Example: int *p;

An important use of a pointer is that when a pointer is declared, assigned the address of another variable and accessing the pointer, we are actually accessing the value at the address assigned to the pointer variable.

Example:
   int x= 10; // variable declaration.
   int *p; // pointer variable
   p = &x; // store address of x in pointer variable

Now the value in *p is 10.

Variable : A variable is a name given to a memory location so that it can be used during manipulations in the program. Every variable has a type based upon the value its holds. Based upon this type the size of the size of the memory to be allocated is decided. This means that when you create a variable you reserve some space in memory.

Declaring a variable means telling the compiler where and how much memory should be callocated to the variable.

Declaration of a variable is shown below:

datatype variable-name;

example: int x;

Here x is a variable of type int. We can also set an initial value to a variable as shown below:

int x=10;

While giving a name to a variable we should specific that doesn\'t contain any special characters except underscore(_). Using aplhabets,digits and underscore in variable names is legal.


Data type : In programming we have situations where we need to store different types of data such as integers,characters,decimal values, etc. Data types are used when declaring a variable. Its tells the compiler what type of data a variable holds. The compiler allocates memory and decides what can be stored in the memory based on the datatype used when defining a variable.
There are several datatpes used in c++.
The basic datatypes used are:

Type Keyword Size(in memory)

Integer int 2bytes
Floating point float 4bytes
Character char 1byte
Double floating point   double 8bytes

what is the definition of the the following in C++ ? (brief definition) 1- Argument 2- Pointer 3- Variable 4- Data typeSolutionArgument: Arguments are values th
what is the definition of the the following in C++ ? (brief definition) 1- Argument 2- Pointer 3- Variable 4- Data typeSolutionArgument: Arguments are values th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site