176k views
5 votes
I. Using your text book, or an Internet search (you can ask your TA) or simply by experimenting with C, explain in a few sentences the difference between arguments and parameters and the purpose of the return statement in functions.

ii. Using your text book, or an Internet search (you can ask your TA) or simply by experimenting with C, explain in a few sentences the difference between the * and the \& operators (* related to pointers, not the multiplication operator).

User Guy Lowe
by
7.3k points

1 Answer

2 votes

Final answer:

In C, parameters are placeholders in a function definition, whereas arguments are the actual values passed to the function. The return statement ends function execution and provides a value back to the caller. The * operator dereferences a pointer, and the & operator gets the address of a variable.

Step-by-step explanation:

Difference Between Arguments and Parameters

While working with functions in C, it’s important to understand that parameters are the variables that are listed as part of a function's declaration or definition. They act as placeholders for the values that the function will work on. On the other hand, arguments are the actual values that you pass into a function when you call it. Arguments are the data you give to the parameters as input.

Purpose of Return Statement

The return statement in functions serves to conclude the function's execution and to specify the value that is to be returned to the caller of the function. This value can then be used for further processing or decisions within the calling code.

Difference Between * and & Operators in C

In the context of pointers in C, the * operator, when used with a pointer variable, dereferences the pointer; that is, it allows you to access the value at the memory address the pointer is pointing to. Conversely, the & operator is used to obtain the memory address of a variable, essentially allowing you to create a pointer to that variable.

User Yoosaf Abdulla
by
8.5k points

No related questions found