# Dexterity - 'c Programming Contest'

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Ravindergoud07
R
Ravindergoud07
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,305
Questions: 20 | Attempts: 1,305  Settings  Organizing by IT Department

• 1.

### Which of the following is not a valid variable name declaration?

• A.

Int _a9;

• B.

Int a_9;

• C.

Int 9_a;

• D.

Int _9a

C. Int 9_a;
Explanation
The variable name "int 9_a;" is not a valid declaration because it starts with a number, which is not allowed in variable names. Variable names in most programming languages must start with a letter or an underscore.

Rate this question:

• 2.

### Which of the following is a valid C variable name?

• A.

Int number;

• B.

Float floating;

• C.

double doubleint;

• D.

All

D. All
Explanation
All of the given options are valid C variable names. In C, a variable name can consist of letters, digits, and underscores. It must start with a letter or an underscore and cannot be a reserved word. The variable names "number", "floating", and "doubleint" all adhere to these rules and are therefore valid C variable names.

Rate this question:

• 3.

### Which is correct with respect to size of the datatypes?

• A.

Char > int > float

• B.

Int > char > float

• C.

Char < int < double

• D.

Double > char > int

C. Char < int < double
Explanation
The correct answer is "char < int < double" because in terms of size, a char data type is smaller than an int data type, and an int data type is smaller than a double data type.

Rate this question:

• 4.

### Which of the following is the correct order of evaluation for the below expression? z = x + y * z / 4 % 2 - 1

• A.

* / % + - =

• B.

= * / % + -

• C.

/ * % - + =

• D.

* % / - + =

A. * / % + - =
Explanation
The correct order of evaluation for the expression is as follows: multiplication (*), division (/), modulus (%), addition (+), and subtraction (-). This means that the multiplication operation is performed first, followed by division, modulus, addition, and finally subtraction.

Rate this question:

• 5.

### What is the output of this C code? int main() { int x = 2, y = 0; int z = (y++) ? y == 1 && x : 0; printf("%d\n", z); return 0; }

• A.

1

• B.

0

• C.

Undefined behavior

• D.

Compile time error

B. 0
Explanation
In this code, the variable "y" is incremented using the post-increment operator. The expression "(y++)" evaluates to false because the value of "y" before the increment is 0. Therefore, the condition of the ternary operator is false and the value of "z" is assigned as 0. Finally, the value of "z" is printed, which is 0.

Rate this question:

• 6.

### Which of the following is not an arithmetic operation?

• A.

A *= 10;

• B.

A /= 10;

• C.

A != 10;

• D.

A %= 10;

C. A != 10;
Explanation
The given options are all arithmetic operations except for "a != 10". The other options, a *= 10, a /= 10, and a %= 10, are all examples of arithmetic operations where the value of 'a' is modified based on the operation performed. However, "a != 10" is a comparison operation, specifically a not-equal-to comparison, which checks if the value of 'a' is not equal to 10. Therefore, "a != 10" is not an arithmetic operation.

Rate this question:

• 7.

### What is the output of this C code?     #include <stdio.h>     void main()     {         double x = 123828749.66;         int y = x;         printf("%d\n", y);         printf("%lf\n", y);     }

• A.

0, 0.0

• B.

123828749, 123828749.66

• C.

12382874, 12382874.0

• D.

123828749, 0.000000

D. 123828749, 0.000000
Explanation
The code declares a double variable x and initializes it with the value 123828749.66. Then, it declares an integer variable y and assigns the value of x to y. When a double value is assigned to an integer variable, the decimal part is truncated. Therefore, y will have the value 123828749.

In the first printf statement, the %d format specifier is used to print the value of y as an integer, so it will output 123828749.

In the second printf statement, the %lf format specifier is used to print the value of y as a double, so it will output 0.000000.

Rate this question:

• 8.

### What is the output of this C code?     #include <stdio.h>     void main()     {         int x = 4, y, z;         y = --x;         z = x--;        printf("%d%d%d", x,  y, z);     }

• A.

3 2 3

• B.

2 3 3

• C.

3 2 2

• D.

2 3 4

B. 2 3 3
Explanation
The code begins by assigning the value 4 to the variable x. Then, the value of x is decremented by 1 and assigned to the variable y using the pre-decrement operator (--x). So, y becomes 3 and x becomes 3. Next, the value of x (which is now 3) is assigned to the variable z using the post-decrement operator (x--). So, z becomes 3 and x becomes 2. Finally, the printf statement prints the values of x, y, and z, which are 2, 3, and 3 respectively. Therefore, the output of the code is 2 3 3.

Rate this question:

• 9.

### Property which allows to produce different executable for different platforms in C is called?

• A.

File inclusion

• B.

Selective inclusion

• C.

Conditional compilation

• D.

Recursive macros

C. Conditional compilation
Explanation
Conditional compilation is the property in C that allows the production of different executables for different platforms. It allows certain sections of code to be included or excluded during the compilation process based on specific conditions. This enables developers to write platform-specific code and customize the behavior of the program based on the target platform. By using conditional compilation directives such as #ifdef and #endif, different code paths can be selected for different platforms, ensuring that the executable produced is tailored to the specific requirements of each platform.

Rate this question:

• 10.

### What will be the output of the following program? #include<stdio.h> #define square(x) x*x  void main() {        int i;        i = 64/square(4);        printf("%d", i);  }

• A.

4

• B.

64

• C.

16

• D.

None

B. 64
Explanation
The program defines a macro called square which takes a parameter x and returns the square of x. In the main function, the variable i is assigned the value of 64 divided by the result of square(4), which is 4*4. Therefore, i is assigned the value of 64/16, which is 4. The printf statement then prints the value of i, which is 4.

Rate this question:

• 11.

### What is the output of this C code?     #include <stdio.h>     const int a = 1,  b = 2;     int main()     {         int x = 1;         switch (x)         {         case a:             printf("yes ");         case b:             printf("no\n");             break;         }    }

• A.

Yes no

• B.

Yes

• C.

No

• D.

Compile time error

D. Compile time error
Explanation
The code will result in a compile-time error because the case labels in a switch statement must be constant expressions. In this code, the case labels are variables (a and b) which are not constant expressions. Therefore, the code will not compile successfully.

Rate this question:

• 12.

### Comment on the output of this C code?     #include <stdio.h>     int main()     {         int a = 1;         if (a)       printf("All is Well ");    printf("I am Well\n");         else             printf("I am not a River\n");     }

• A.

Output will be All is Well I am Well

• B.

Output will be I am Well I am not a River

• C.

Output will be I am Well

• D.

Compile time errors during compilation

D. Compile time errors during compilation
Explanation
The code will not produce any compile time errors. The if statement checks if the variable "a" is true or non-zero. Since "a" is initialized to 1, the condition will be true and the code inside the if block will be executed. Therefore, the output will be "All is Well I am Well".

Rate this question:

• 13.

### What will be the value of i and j after execution of following program? #include<stdio.h> void main() { int i, j; for(i=0,j=0;i<10,j<20;i++,j++) { printf("i=%d %t j=%d", i, j); } }

• A.

10 10

• B.

10 20

• C.

20 20

• D.

Run time error

C. 20 20
Explanation
The program includes a for loop that iterates as long as both i is less than 10 and j is less than 20. It increments both i and j by 1 after each iteration. The loop will continue until either i becomes equal to 10 or j becomes equal to 20. Since i and j are incremented by 1 in each iteration, the loop will execute a total of 10 times. Therefore, after the execution of the program, the final values of i and j will be 10 and 20 respectively.

Rate this question:

• 14.

### What is the output of this C code?     #include <stdio.h>     int main()     {         int i = 0;         while (i = 0)             printf("True\n");         printf("False\n");     }

• A.

True (infinite time)

• B.

True (1 time) False

• C.

False

• D.

Compile error

C. False
Explanation
The code will output "False". This is because the condition in the while loop is "i = 0", which is an assignment statement rather than a comparison. As a result, the value of "i" will always be set to 0 and the loop will never be executed. Therefore, the program will directly move to the statement after the while loop, which is the printf statement that prints "False".

Rate this question:

• 15.

### What is the output of this C code?     #include <stdio.h>     int main()     {    printf("before continue ");         continue;   printf("after continue\n");     }

• A.

Before continue after continue

• B.

Before continue

• C.

After continue

• D.

Compile time error

D. Compile time error
Explanation
The output of this C code is "Compile time error". This is because the "continue" statement is used outside of a loop, which is not allowed in C. The "continue" statement is used to skip the rest of the current iteration of a loop and move on to the next iteration. Since there is no loop in this code, using "continue" results in a compile time error.

Rate this question:

• 16.

### Comment on the following statement:  int (*a);

• A.

An array “a” of pointers.

• B.

A pointer “a” to an array.

• C.

A ragged array.

• D.

None of the mentioned

B. A pointer “a” to an array.
Explanation
The statement "int (*a)" declares a pointer "a" to an array of 7 integers. This means that "a" can store the memory address of an array, and that array must have 7 elements, each of which is an integer. The parentheses around "*a" indicate that "a" is a pointer, and the "" indicates that it points to an array of size 7. Therefore, the correct answer is "A pointer 'a' to an array."

Rate this question:

• 17.

### What is the output of this C code?     #include <stdio.h>     void main()     {  int a = {1, 2, 3, , 4, 5};         int i = 0, j = 0;         for (i = 0; i < 2; i++)         for (j = 0; j < 3; j++)         printf("%d", a[i][j]);     }

• A.

1 2 3 junk 4 5

• B.

Compile time error

• C.

1 2 3 0 4 5

• D.

1 2 3 3 4 5

B. Compile time error
Explanation
The given code will result in a compile time error. This is because there is a missing value in the initialization of the array "a". In the second row of the initialization, there is a comma without a value, which is not allowed. Therefore, the code will fail to compile.

Rate this question:

• 18.

### What is the output of this C code?     #include <stdio.h>     void main()     {         static int x = 3;         x++;         if (x <= 5)         {             printf("hi");             main();         } }

• A.

Run time error

• B.

Hi

• C.

Infinite hi

• D.

Hi hi

D. Hi hi
Explanation
The output of this C code is "hi hi". The code defines a static variable "x" with an initial value of 3. It then increments "x" by 1. The code then checks if "x" is less than or equal to 5. Since "x" is now 4, the condition is true and the code prints "hi". After printing "hi", the code calls the main() function recursively. This process continues until "x" becomes 6, at which point the condition becomes false and the recursion stops. Therefore, "hi" is printed twice, resulting in the output "hi hi".

Rate this question:

• 19.

### Which files will get closed through the fclose() in the following program? #include<stdio.h> int main() {     FILE *fs, *ft, *fp;     fp = fopen("A.C", "r");     fs = fopen("B.C", "r");     ft = fopen("C.C", "r");     fclose(fp, fs, ft);     return 0; }

• A.

"A.C" "B.C" "C.C"

• B.

"B.C" "C.C"

• C.

"A.C"

• D.

Error in fclose()

D. Error in fclose()
Explanation
The fclose() function in C is used to close a file. However, fclose() can only close one file at a time. In the given program, the fclose() function is called with three arguments (fp, fs, ft), which is incorrect. Therefore, the correct answer is "Error in fclose()" as the fclose() function cannot close multiple files simultaneously.

Rate this question:

• 20.

### What will be the output of the program ? #include<stdio.h> int main() {     enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};     printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);     return 0; }

• A.

-1, 0, 1, 2, 3, 4

• B.

-1, 2, 6, 3, 4, 5

• C.

-1, 0, 6, 2, 3, 4

• D.

-1, 0, 6, 7, 8, 9

D. -1, 0, 6, 7, 8, 9
Explanation
The program defines an enumeration called "days" with the values MON=-1, TUE=0, WED=6, THU=7, FRI=8, and SAT=9. In the printf statement, the values of MON, TUE, WED, THU, FRI, and SAT are printed. Therefore, the output of the program will be -1, 0, 6, 7, 8, 9.

Rate this question:

Related Topics Back to top