C Programming MCQ Exam!

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 Chandra
C
Chandra
Community Contributor
Quizzes Created: 1 | Total Attempts: 378
| Attempts: 378 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Which of the following is not the usual practice in declaring variables as volatile?

Explanation

Static variables are not typically declared as volatile because they are not shared between multiple tasks or threads. Volatile is used to indicate that a variable may be modified by external sources, such as interrupts or other threads, and therefore needs to be accessed directly from memory rather than from a cached value. Static variables, on the other hand, are local to a specific function or module and are not accessed by multiple tasks or threads. Therefore, there is no need to declare them as volatile.

Submit
Please wait...
About This Quiz
C Programming MCQ Exam! - Quiz

Are you ready for this C Programming quiz? This quiz answers such questions as what the const feature can be applied to, the correct value to return to the operating system, what are not qualifiers in C, and the usual practice in declaring variables as volatile. Get ready to be... see moretested on complex computer language. This quiz will test you about the C programming language. All the best. see less

Personalize your quiz and earn a certificate with your name on it!
2. The "const" feature can be applied to?

Explanation

The "const" feature can be applied to an array argument, an identifier, and an array. This means that all three options mentioned in the question can have the "const" feature applied to them.

Submit
3. What is the output? int main(void)    {          static char food[] ="Yummy";       char *ptr;        ptr = food+strlen(food);        printf("%p",ptr);        return 0; }

Explanation

The code initializes a static character array named "food" with the value "Yummy". It then declares a character pointer "ptr" and assigns it the address of the last character in the "food" array using the "strlen" function. Finally, it prints the value of "ptr" using the "%p" format specifier, which is the hexadecimal representation of the memory address where the character 'y' is stored. Therefore, the output will be the address of the character 'y'.

Submit
4. What is the output? int main() {    char *s="Abcat";    printf("%s",s+s[1]-s[3]);      }  

Explanation

The code is using pointer arithmetic to calculate the address of the start of a substring within the string "Abcat". By subtracting the ASCII values of the characters 'c' and 'A' from the address of 's', it is able to find the address of the substring "bcat". The printf statement then prints this substring, resulting in the output "bcat".

Submit
5. What is the output ?void f(char *);int main(int argc, char** argv){f("123");}void f(char a[]){if(a[1] =='\0') return;f(a+1);f(a+1);printf("%c", a[1]);} 

Explanation

The function f is called with the string "123" as an argument. In the function f, the condition a[1] == '\0' is checked. Since a[1] is not equal to '\0', the function calls itself recursively twice, each time with the argument a+1. This means that the function f is called with "23" and then with "3". When the condition a[1] == '\0' is finally true, the function returns. The printf statement then prints the value of a[1], which is '3'. Therefore, the output is "332".

Submit
6. int main(void){    int x = 2, y, z;    x *= 3 + 2;    x *= y = z = 4;    printf("%d \n", x);    x = y == z;    printf("%d \n", x);    return 0;}

Explanation

The code starts by assigning the value 2 to variable x. Then, it multiplies x by the result of 3 + 2, which is 5, so x becomes 10. Next, it multiplies x by the result of y = z = 4, which is also 4. Therefore, x becomes 40. The first printf statement prints the value of x, which is 40. Then, the code assigns the result of y == z to x. Since y and z are both 4, the result is 1 (true). Therefore, the second printf statement prints the value of x, which is 1.

Submit
7. What is output? int  main() {           int x[ ] = { 1, 4, 3, 5, 1, 4 };        int *ptr, y;      ptr = x + 4;      y = ptr - x;        printf("%d",y);   }

Explanation

The code initializes an array "x" with values {1, 4, 3, 5, 1, 4}. It then declares a pointer variable "ptr" and an integer variable "y". The pointer "ptr" is assigned the address of the element at index 4 of array "x". The variable "y" is assigned the difference between the address of "ptr" and the address of the first element of array "x". Finally, the value of "y" is printed, which is 4.

Submit
8. What is the output?     int main()     {        int i = 2*3 /4+4/ 4+3- 2+ 5 / 3;         printf("%d",i);         } 

Explanation

The correct answer is "None of the above". The output of the code is 7. The expression is evaluated from left to right, following the order of operations. First, 2*3 is calculated which equals 6. Then, 6/4 is calculated which equals 1. Next, 4/4 equals 1. Then, 1+1+3-2 equals 3. Finally, 5/3 equals 1. The final result is 3+1 which equals 4. Therefore, the output is 4, not any of the options given.

Submit
9. What is the correct value to return to the operating system upon the successful?

Explanation

None of the given options (Null, 1, -1) is a correct value to return to the operating system upon success. The correct value to return would depend on the specific context and requirements of the operating system or program.

Submit
10. What are not qualifiers in C? 

Explanation

Const is a qualifier in C that is used to declare a variable as a constant, meaning its value cannot be changed once it is assigned. Static and volatile are also qualifiers in C, but they are not included in the list of options given. Therefore, the correct answer is Const.

Submit
View My Results

Quiz Review Timeline (Updated): Nov 16, 2023 +

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

  • Current Version
  • Nov 16, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 20, 2013
    Quiz Created by
    Chandra
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following is not the usual practice in declaring...
The "const" feature can be applied to?
What is the output?...
What is the output?...
What is the output ?void f(char *);int main(int argc, char**...
Int main(void){    int x = 2, y, z;    x...
What is output?...
What is the output? ...
What is the correct value to return to the operating system upon the...
What are not qualifiers in C? 
Alert!

Advertisement