Answer:
Following are the code in the C programming Language.
//define function
void duplicate(char*argv, char**result) {
//set and initialize the variable to 0
int c = 0;
//set and initialize the char type pointer variable
char** t = argv;
//set the while loop
while(t){
//increment by 1
c++;
//increment by 1
t++;
}
//set malloc function in the pointer variable
result= malloc(sizeof(char)*(c+1));
//set the for loop
for(int i = 0; i < c; i++) {
//set malloc function in the pointer
(*result)[i] = malloc(strlen(argv[i])+1);
//copy the character from memory
memcpy(argv[i], (*result)[i], strlen(argv[i])+1)
;
}
//initialize null in the pointer
(*result)[i] = NULL;
}
Explanation:
In the following code, we define function "duplicate()" and pass two character type pointer arguments "*argv" and "**result" and inside the function.
- Set an integer type variable "c" and initialize to 0.
- Set character type pointer variable "t" and initialize the value of pointer variable "argv".
- Set the while loop and increment in the variable "c" and "t" by 1.
- Set the malloc function in the pointer variable "result".
- Set the for loop to copy the character from the memory.
- Finally, initialize the pointer variable "result" to NULL.
A multidisciplinary, post-Master<span> educational program which provides practical training in the field of </span>human-computer interaction and user interface design<span>.</span>
Answer:
10 20
30 40
50 60
Explanation:
Given
The above code segment
Required
What is printed, if anything
To do this, we analyze the code line by line.
Line 1: The first line creates a 4 by 3 array named mat
Line 2: for (int[] row : mat)
{ -> This creates row[] array which represents each row of array mat
Line 3: for (int j = 0; j < row.length; j += 2){ -> This iterates through the even indexed elements of the row array i.e. 0 and 2
Line 4: System.out.print(row[i] + " "); -> This prints the even indexed elements of the row array.
The even indexed elements are: 10, 20, 30, 40, 50 and 60
Line 5: System.out.println();
--> This prints a new line
Use Cite This For Me's APA citation generator to create a reference page in APA format with all websites.