Tag: programming languages

Questions Related to programming languages

Which one of the following C operators is right associative?

  1. =

  2. ,

  3. []

  4. ->


Correct Option: A

char ** array [12][12][12]; Consider array, defined above. Which one of the following definitions and initializations of p is valid?

  1. char ** (* p) [12][12] = array;

  2. char ***** p = array;

  3. char * (* p) [12][12][12] = array;

  4. const char ** p [12][12][12] = array;


Correct Option: A
Explanation:

To solve this question, the user needs to be familiar with C/C++ syntax and the concept of pointers.

A. char ** (* p) [12][12] = array;

This option is valid. p is a pointer to a 3D array of char pointers. It is initialized to point to the first element of the array using the assignment operator =.

B. char ***** p = array;

This option is not valid. p is a pointer to a pointer to a pointer to a pointer to a pointer to a char, which is not compatible with the type of array.

C. char * (* p) [12][12][12] = array;

This option is not valid. p is a pointer to a 4D array of char pointers, which is not compatible with the type of array.

D. const char ** p [12][12][12] = array;

This option is not valid. p is a 3D array of const char pointers, which is not compatible with the type of array.

Therefore, the only valid option is:

The Answer is: A

  1. efg

  2. cdefg

  3. fg

  4. None of the above


Correct Option: C
Explanation:

To solve this question, the user needs to understand the concept of pointers in C programming. In this case, ptr is a pointer variable that points to the first character of the myString array. The statement ptr += 5 increments the pointer by 5, so that it now points to the sixth character in the array.

Option A is incorrect because ptr is pointing to the sixth character in the array, not the third.

Option B is incorrect because ptr is pointing to the sixth character in the array, not the first.

Option C is correct because ptr is pointing to the sixth character in the array, which is "f", and continues to the end of the string, "g". Therefore, the string that ptr points to is "fg".

Option D is incorrect because an answer was provided above.

Therefore, the answer is: C. fg

time_t t; Which one of the following statements will properly initialize the variable t with the current time from the sample above

  1. t = ctime();

  2. time( &t );

  3. t = localtime();

  4. t = clock();


Correct Option: D

AI Explanation

To properly initialize the variable t with the current time, you can use the time() function from the ctime library.

Option A) t = ctime(); - This option is incorrect because the ctime() function returns a string representation of the current time, not the actual time value.

Option B) time( &t ); - This option is correct because it calls the time() function and passes the address of t as an argument, allowing time() to store the current time value in t.

Option C) t = localtime(); - This option is incorrect because the localtime() function converts a time value into a broken-down time structure, not the current time.

Option D) t = clock(); - This option is incorrect because the clock() function measures the processor time, not the current time.

The correct answer is Option B.

int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What number will z in the sample code above contain?

  1. 12

  2. 10

  3. 11

  4. 6


Correct Option: B

AI Explanation

To find the value of z in the given code, let's break down the expression step by step:

  1. x++ increments the value of x by 1 after it is used in the expression. So, the value of x is now 6.

  2. --y decrements the value of y by 1 before it is used in the expression. So, the value of y is now -11.

  3. y * b multiplies the value of y (-11) by the value of b (2), resulting in -22.

  4. -22 / a divides the value of -22 by the value of a (4), resulting in -5.5.

  5. Finally, z = 6 - (-5.5), which simplifies to z = 6 + 5.5. Therefore, z equals 11.5.

However, since the given variables are integers, the result will be truncated to the nearest integer. So, z will contain the value 11.

Therefore, the correct answer is option C) 11.

What number is equivalent to -4e3?

  1. -400

  2. .004

  3. -4000

  4. .0004


Correct Option: C
Explanation:

To solve this question, the user needs to know the concept of scientific notation. In scientific notation, a number is expressed as the product of a coefficient and a power of 10. The coefficient is a number between 1 and 10, and the power of 10 represents the number of places the decimal point must be moved to obtain the original number.

The notation -4e3 means -4 times 10 to the power of 3, or -4 multiplied by 1000. This gives us -4000.

Now, let's go through each option and explain why it is right or wrong:

A. -400: This option is incorrect because -400 is not equal to -4e3. A negative exponent in scientific notation represents a number less than 1, so -4e3 is a negative number with a large absolute value.

B. .004: This option is incorrect because .004 is not equal to -4e3. A positive exponent in scientific notation represents a large number, so -4e3 is a negative number with a large absolute value.

C. -4000: This option is correct. As explained earlier, -4e3 means -4 times 10 to the power of 3, or -4 multiplied by 1000. This gives us -4000.

D. .0004: This option is incorrect because .0004 is not equal to -4e3. A positive exponent in scientific notation represents a large number, so -4e3 is a negative number with a large absolute value.

Therefore, the answer is:

The Answer is: C

Which one of the following is not written in Delphi?

  1. Skype

  2. Toad

  3. PL/SQL Developer

  4. MySQL

  5. MySQL Administrator


Correct Option: D

Find out the odd one.

  1. Embarcadero

  2. CodeGear

  3. Inprise

  4. Borland

  5. Pascal


Correct Option: E