Question

In: Computer Science

1 Commenting in C There are two mechanisms in C to declare comments: 1. Commenting in...

1 Commenting in C
There are two mechanisms in C to declare comments:
1. Commenting in a single line using // at the beginning, and
2. Commenting in potentially multiple lines using /* to mark the beginning and */ to mark the ending.
For each of the following criteria, argue which commenting mechanism is more preferred.
readability,
writability, and
reliability

Solutions

Expert Solution

1. Readability:

For this criteria single line commenting is more prefered because it exactly explains what the particular line or a block of code is doing and it is simple so becomes easier for another programmer to look into the code and understand the purpose of the each line in the code based on the comment.

for example:

// find marks in percentage

percentage =(marks_scored/total marks) *100

2. Writability:

for this criteria also single line commenting is more prefered because in this case it is easier to make changes in the comments later on if we have made any changes in the coding part.if we use multi line commenting then it becomes a bit difficult to make changes without the use of IDE's

3. Reliability:

Multiple line commenting should be used if we want to make our code more reliable because here we can explain the purpose of the code along of other details, so it becomes a bit easier to find out the errors in the code.By looking at the comment programmer will be able to understand the purpose of using a particular function or a block of statements and so he can find out what would have caused the error in the code


Related Solutions

C++ Program 1. Declare an integer static array a[ ] with 100 elements. 2. Declare an...
C++ Program 1. Declare an integer static array a[ ] with 100 elements. 2. Declare an integer pointer p. 3. Let p pointing to the array a[ ]. 4. Use p (you have to use p) to put 0 into the first element of this array, 2 into the second element, 4 into the 3rd element, 6 into the 4th element, ... 198 into the 100th element of this array. 5. Use a (you have to use a) to display...
Write a program in c++ to do the following : (1) Declare an array a of...
Write a program in c++ to do the following : (1) Declare an array a of size 10 and three pointer variables p, q, and v. (2) Write a loop to fill array a with values 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 (3) write following statement: p= &a[2]; q = &a[5]; i = *q - *p; cout<<“The value of i is”<< i; i = *p - *q; cout<<“The value of i is %d”<< i; 4) assign...
1.Declare a two-dimensional array of Strings namedchessboard.
1. Declare a two-dimensional array of Strings named chessboard.2. Declare a two-dimensional array of integers named tictactoe.3. Declare and create a two-dimensional array of chars,tictactoe, with 3 rows, each with 3 elements.4. Create a two-dimensional array of ints, plan, with 2 rows, and and 3 columns and initialize the first row to 8, 20, 50 and the second row to 12, 30, 75. Use member initializer syntax.
Please answer this using MATLAB (Not c or c++) and make sure to provide proper commenting:...
Please answer this using MATLAB (Not c or c++) and make sure to provide proper commenting: a. Write a function that writes a series of random Fahrenheit temperatures and their corresponding Celsius temperatures to a tab-delimited le. Use 32 to 212 as your temperature range. From the user, obtain the following: 1) The number of temperatures to randomly generate. 2) The name of the output file. b. Write a function that reads a file produced by part (a). Focusing only...
Provide code samples for the following in C#a. Declare a two-dimensional array of integers names...
Provide code samples for the following in C#a. Declare a two-dimensional array of integers names intArray17.b. Create a loop to calculate the sum of every element in the first column.c. Create a loop to calculate the sum of every element in the array.
In C# - Provide code samples for the following: Declare a two-dimensional array of integers names...
In C# - Provide code samples for the following: Declare a two-dimensional array of integers names intArray17. Create a loop to calculate the sum of every element in the first column. Create a loop to calculate the sum of every element in the array.
Declare two int: x and y Declare two pointers p and q capable of pointing to...
Declare two int: x and y Declare two pointers p and q capable of pointing to int Make p point to y Make q point to x Assign 3 and 6 to x and y without mentioning x and y Redirect p to point to the same location q points to (two ways) Make q point to y Swap the values of x and y without mentioning x and y Declare two int: x and y Declare two pointers p...
Declare two int: x and y Declare two pointers p and q capable of pointing to...
Declare two int: x and y Declare two pointers p and q capable of pointing to int Make p point to y Make q point to x Assign 3 and 6 to x and y without mentioning x and y Redirect p to point to the same location q points to (two ways) Make q point to y Swap the values of x and y without mentioning x and y Declare two int: x and y Declare two pointers p...
Write in C++ and insert comments. Input two values a and b 0 may be used...
Write in C++ and insert comments. Input two values a and b 0 may be used for False 1 may be used for True Write a program that will print the truth table for the logical operator and give the results for the specific input a, b. The following logical operators should be coded. ● conjunction (AND) ● disjunction (OR) ● conditional Statement (If a then b) ● exclusive OR (XOR) ● biconditional operation (p iff q) Example for conjunction...
Recursion and Iteration in C++ Locate the TODO comments in the hw02.h file. These comments provide...
Recursion and Iteration in C++ Locate the TODO comments in the hw02.h file. These comments provide direction on what needs to be done. // hw02.h #ifndef CSC232_HW02_H #define CSC232_HW02_H // TODO: All pre-conditions must be validated using the assert function imported from the following library. // TODO: You are not allowed to use the pow function in this assignment! #include <cassert> #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE !FALSE #endif #define USE_MAIN_INPUT_FILE FALSE #define USE_DEMO_INPUT_FILE FALSE #define...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT