Differences Between Structure and Union in Programming, Summaries of Computer Science

The key differences between the programming concepts of structure and union. It provides a detailed comparison across various parameters such as basics, representation, dimensions, parameter receiving, total size, and the differences between call-by-value and call-by-reference methods of parameter passing. Additionally, it delves into the distinctions between actual and formal parameters, as well as the differences between syntax and logical errors in programming. This comprehensive overview offers valuable insights for students and professionals studying or working in the field of computer science and programming.

Typology: Summaries

2022/2023

Uploaded on 12/03/2023

gur-preet-3
gur-preet-3 🇮🇳

1 document

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Differences between Structure and Union
Differences between Structure and Union are as shown below in tabular format
as shown below as follows:
Difference Between One-Dimensional and Two-
Dimensional Array
pf3
pf4
pf5

Partial preview of the text

Download Differences Between Structure and Union in Programming and more Summaries Computer Science in PDF only on Docsity!

Differences between Structure and Union

Differences between Structure and Union are as shown below in tabular format as shown below as follows:

Difference Between One-Dimensional and Two-

Dimensional Array

Parameters One-Dimensional Array Two-Dimensional Array Basics A one-dimensional array stores a single list of various elements having a similar data type. A two-dimensional array stores an array of various arrays, or a list of various lists , or an array of various one-dimensional arrays. Representation It represents multiple data items in the form of a list. It represents multiple data items in the form of a table that contains columns and rows. Dimensions It has only one dimension. It has a total of two dimensions. Parameters of Receiving One can easily receive it in a pointer, an unsized array, or a sized array. The parameters that receive it must define an array’s rightmost dimension. Total Size (in terms of Bytes) Total number of Bytes = The size of array x the size of array variable or datatype. Total number of Bytes = The size of array visible or datatype x the size of second index x the size of the first index.

Difference between the Call by Value and Call by

Reference

The following table lists the differences between the call-by-value and call-by- reference methods of parameter passing.

Call By Value Call By Reference

While calling a function, we pass the values of variables to it. Such functions are known as “Call By Values”. While calling a function, instead of passing the values of variables, we pass the address of variables(location of variables) to the function known as “Call By References. In this method, the value of each variable in the calling function is copied into corresponding dummy variables of the called function. In this method, the address of actual variables in the calling function is copied into the dummy variables of the called function. With this method, the changes made to the dummy variables in the called With this method, using addresses we would have access to the actual variables and hence

Actual Parameters Formal Parameters

When a function is called, the values (expressions) that are passed in the function call are called the arguments or actual parameters. The parameter used in function definition statement which contain data type on its time of declaration is called formal parameter. These are the variables or expressions referenced in the parameter list of a subprogram call. These are the variables or expressions referenced in the parameter list of a subprogram specification. Actual Parameters are the parameters which are in calling subprogram. Formal Parameters are the parameters which are in called subprogram. There is no need to specify datatype in actual parameter. The datatype of the receiving value must be defined. The parameters are written in function call are known as actual parameters. The parameters are written in function definition are known as formal parameters. Actual Parameters can be constant values or variable names. Formal Parameters can be treated as local variables of a function in which they are used in the function header.

Difference between Syntax and Logical Errors

Syntax Error Logical Error

 This is the error that occurs

due to the violation of

syntax rules of a particular

programming language. this

usually happens when we

 This type of error causes

unexpected and unusual

results for the program.

change the intended syntax of writing the sequence of tokens or characters.  The program terminates due to such errors and cannot execute successfully until we rectify it.  It does not cause termination of the program abnormally.  The cause is the fault in the program syntax.  The cause is the fault in the logic or algorithm.  The compiler indicates the error and its location itself in compiled languages.  The programmer has to find the error himself.  It is easier to detect a syntax error.  On the other hand, finding a logical error is comparatively more difficult.