C Programming Language Challenge Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Vivek270657
V
Vivek270657
Community Contributor
Quizzes Created: 1 | Total Attempts: 249
| Attempts: 249 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Which of the following does not have an unary operator?

Explanation

The given options include -7, ++j, j, and !i. The unary operator is an operator that operates on a single operand. In this case, the unary operator is the exclamation mark (!) which is used for logical negation. It is applied to the operand i in the expression !i. However, the variable j does not have any unary operator applied to it, making it the correct answer.

Submit
Please wait...
About This Quiz
C Programming Language Challenge Quiz - Quiz

Did you know that the C programming language is a general procedural computer programming language supporting structured programming? It has discovered maximum use in applications that were formerly encoded in assembly language. This application includes operating systems and different application software for computer experts. C is an imperative procedural language.... see moreIt was created to be recorded to deliver low-level access to memory and language. Put your knowledge to the test and take this quiz on C programming language.
see less

Personalize your quiz and earn a certificate with your name on it!
2. The int type of constraints are whole numbers in the range

Explanation

The correct answer is -32768 to 32767. This range represents the valid values for the int data type in programming. The int type is used to store whole numbers, and this range ensures that the values fall within the limits of the data type. Values below -32768 or above 32767 would result in an overflow or underflow, potentially causing unexpected behavior in the program. Therefore, the range of -32768 to 32767 is the correct answer for the int type of constraints.

Submit
3. A union consists of a number of elements that

Explanation

In a union, all the elements occupy the same space in memory. This means that only one element of the union can be stored at a time, and accessing one element may overwrite the value of another element. This is different from a structure, where each element has its own separate space in memory. The elements in a union can have different types, but they all share the same memory space.

Submit
4. Main () {             int a;             a = 3;             e(a); }   void e(int a) {             if(n>0) {                         e(--n);                                                                printf(“%d”,n);                         e(--n);             } }

Explanation

The correct answer is 0120. The code starts with the main function and initializes the variable a with the value 3. Then, it calls the function e with the argument a. In the function e, there is a recursive call to e with the argument n decremented by 1. This means that the function e will be called again with the argument 2. Inside the if statement, there is a printf statement that prints the value of n, which is 2. After that, there is another recursive call to e with the argument n decremented by 1 again, which means the function e will be called with the argument 1. This process continues until n becomes 0. So, the output will be 0120.

Submit
5. Main() {             char a[]=”abcdef”;             char * p = a;             p++;                                                     p++; p[2] = ‘z’; printf(“ %s “,p); }

Explanation

The code initializes a character array "a" with the string "abcdef" and a character pointer "p" pointing to the first element of "a". The code then increments the pointer "p" twice, making it point to the third element of "a". The third element is then assigned the value 'z'. Finally, the code prints the string starting from the pointer "p", which is "cdzf".

Submit
6. Main() {             char *ptr1 = “abcdef”;             ptr1 = ptr1 + (strlen(ptr1)-1); printf(“%c”,--*ptr1--); printf(“%c”,--*--ptr1); printf(“%c”,--*(ptr1--)); printf(“%c”,--*(--ptr1)); printf(“%c”,*ptr1);      }

Explanation

The code initializes a pointer `ptr1` to point to the string "abcdef". The expression `ptr1 = ptr1 + (strlen(ptr1)-1)` moves the pointer to the last character of the string, which is 'f'.

In the first `printf` statement, `--*ptr1--` decrements the value of 'f' to 'e' and then moves the pointer to the previous character, 'e'.

In the second `printf` statement, `--*--ptr1` first moves the pointer to the previous character, 'd', and then decrements its value to 'c'.

In the third `printf` statement, `--*(ptr1--)` decrements the value of 'c' to 'b' and then moves the pointer to the previous character, 'a'.

In the fourth `printf` statement, `--*(--ptr1)` first moves the pointer to the previous character, 'a', and then decrements its value to 'a'.

Finally, in the fifth `printf` statement, `*ptr1` simply prints the value of the current character, which is 'a'.

Therefore, the output of the code is "ecbaa".

Submit
7. Main() {             int q, i, j, count;             i=j=0;             q=2;             count = 6;             switch( 3 )             {                         case 0:                                     while ( --count > 0 ) {                                                 case 1:                                                             ++j;                                                 case 2:                                                             ++i;                                                 case 3:  ;                                                 case 4:  ;                                                 case 5:  ;                                     }             }                         printf(“%d”,i);             printf(“%d”,j); }

Explanation

The code snippet provided uses a switch statement with the value of 3. Since there is no case for 3, the switch statement does nothing and moves to the next line. The while loop then decrements the count variable until it becomes 0. Inside the while loop, there are cases for 1 and 2 which increment the variables j and i respectively. However, there are no cases for 0, 4, and 5, so these cases do nothing. Therefore, after the while loop, the value of i will be 0 and the value of j will be 2. The correct answer is 55, which is the value of j.

Submit
8. If the variables i,j and k are assigned the values 5,3 and 2 respectively, then the expression i=j+(k++ =6)+7;

Explanation

The expression i=j+(k++ =6)+7; gives an error message because the assignment operator (=) is used inside the parentheses. The assignment operator is not allowed in an expression because it does not return a value. Therefore, the expression is not valid and cannot be evaluated.

Submit
9. Void t1 (char *); main() {             char * p;             p = ”abcdef”;             t1(p); }   void t1(char *q) {             if(*q != ‘d’) {                         putchar(*q);                         t1(q++);             } }

Explanation

The given code is a recursive function that prints each character of a string until it encounters the character 'd'. In the main function, the string "abcdef" is passed to the t1 function. Inside the t1 function, the condition *q != 'd' is checked. If the condition is true, the character pointed to by q is printed using putchar(*q). Then, the t1 function is called recursively with q incremented by 1 (q++). Since there is no base case or condition to stop the recursion, the function will continue to be called infinitely, printing 'a' repeatedly.

Submit
10. Main () {             printf (“%d”, sizeof (65555));             printf(“%d”,sizeof(65555L));             printf(“%d”,sizeof(6.5F));             printf (“%d”,sizeof (6.5));             printf(“%d”,sizeof(6.5L)); }

Explanation

The program is using the sizeof operator to determine the size in bytes of different data types. The sizeof operator returns the size of a data type in bytes.

- sizeof(65555) returns 4 because 65555 is an integer value and the size of an integer is typically 4 bytes.
- sizeof(65555L) returns 4 because 65555L is a long integer value and the size of a long integer is also typically 4 bytes.
- sizeof(6.5F) returns 4 because 6.5F is a float value and the size of a float is typically 4 bytes.
- sizeof(6.5) returns 8 because 6.5 is a double value and the size of a double is typically 8 bytes.
- sizeof(6.5L) returns 10 because 6.5L is a long double value and the size of a long double is typically 10 bytes.

Submit
View My Results

Quiz Review Timeline (Updated): Oct 21, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Oct 21, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 22, 2011
    Quiz Created by
    Vivek270657
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following does not have an unary operator?
The int type of constraints are whole numbers in the range
A union consists of a number of elements that
Main () ...
Main() ...
Main() ...
Main() ...
If the variables i,j and k are assigned the ...
Void t1 (char *); ...
Main () ...
Alert!

Advertisement