C Programming Quiz: Output Of C Programs! Trivia

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.
Learn about Our Editorial Process
| By Shamil
S
Shamil
Community Contributor
Quizzes Created: 1 | Total Attempts: 218
Questions: 10 | Attempts: 219

SettingsSettingsSettings
C Programming Quiz: Output Of C Programs! Trivia - Quiz

“C” is a computer programming language, which supports structured programming, recursion, and lexical variable scope. It first appeared in 1972 and variations of it are still used prominently today. What do you know about it?


Questions and Answers
  • 1. 

    )#include void call(int,int,int); int main(){  int a=10; call(a,a++,++a); return 0; } void call(int x,int y,int z){  printf("%d %d %d",x,y,z); }

    • A.

      10 10 12

    • B.

      12 11 11

    • C.

      12 12 12

    • D.

      10 11 12

    • E.

      Compiler error

    Correct Answer
    B. 12 11 11
    Explanation
    The correct answer is 12 11 11. In the main function, the variable a is initially assigned the value 10. The call function is then called with the arguments a, a++, and ++a.

    When the call function is executed, the values of the arguments are passed to the parameters x, y, and z respectively. The value of a is 12 at this point because of the pre-increment operation (++a) in the argument list.

    However, the post-increment operation (a++) in the argument list causes the value of a to be incremented after it is passed to the call function. Therefore, the value of y is 11.

    The value of x is still 10 because it was passed by value before any increment operations.

    So, the output of the call function is 12 11 11.

    Rate this question:

  • 2. 

    #include<stdio.h> int main(){ int a=-20; int b=-3; printf("%d",a%b); return 0; }

    • A.

      2

    • B.

      -2

    • C.

      18

    • D.

      -18

    • E.

      Compiler error

    Correct Answer
    B. -2
    Explanation
    The code snippet defines two variables, 'a' and 'b', with values -20 and -3 respectively. The expression 'a%b' calculates the remainder when 'a' is divided by 'b'. In this case, -20 divided by -3 gives a quotient of 6 and a remainder of -2. Therefore, the output of the program will be -2.

    Rate this question:

  • 3. 

    #include<stdio.h> int main(){  char *url="c:\tc\bin\rw.c";  printf("%s",url); return 0; }

    • A.

      C:\tc\bin\rw.c

    • B.

      C:/tc/bin/rw.c

    • C.

      C: c inw.c

    • D.

      C:cinw.c

    • E.

      W.c in

    Correct Answer
    E. W.c in
    Explanation
    The given code is a C program that prints the value of the variable "url" using the printf function. The variable "url" is assigned the value "c:\tc\bin\rw.c". The printf function then prints this value, which is "w.c in". Therefore, the correct answer is "w.c in".

    Rate this question:

  • 4. 

    Which of the following is not derived data type in c?

    • A.

      Function

    • B.

      Pointer

    • C.

      Enumeration

    • D.

      Array

    • E.

      All the above

    Correct Answer
    C. Enumeration
    Explanation
    An enumeration is not a derived data type in C. Derived data types are created by combining or modifying existing data types. Examples of derived data types in C include arrays, functions, and pointers. However, an enumeration is a user-defined data type that consists of a set of named values. It is used to define a list of constants that can be assigned to a variable. Therefore, the correct answer is enumeration.

    Rate this question:

  • 5. 

    The function which is used to move the file pointer to any desired location within a file?

    • A.

      Fseek()

    • B.

      Ftell()

    • C.

      Rewind()

    • D.

      Both a and b

    Correct Answer
    A. Fseek()
    Explanation
    The fseek() function is used to move the file pointer to any desired location within a file. It allows us to set the position indicator of the file stream to a specific offset from a reference point. This reference point can be the beginning, end, or current position of the file. By using fseek(), we can easily navigate through a file and perform operations at specific positions.

    Rate this question:

  • 6. 

    #include<stdio.h> int main(){  int a=15,b=10,c=5;  if(a>b>c )    printf("True");  else    printf("False"); return 0; }

    • A.

      True

    • B.

      False

    • C.

      Run time error

    • D.

      Compiler error

    • E.

      None of above

    Correct Answer
    B. False
    Explanation
    The code snippet compares three variables a, b, and c using the greater than operator (>). Since 15 is not greater than 10, the condition in the if statement evaluates to false. Therefore, the code will execute the else block and print "False".

    Rate this question:

  • 7. 

    What will be the output when you will execute following c code? #include<stdio.h> void main(){ char arr[7]="Network"; printf("%s",arr); }

    • A.

      Network

    • B.

      N

    • C.

      Garbage value

    • D.

      Compilation error

    • E.

      None of the above

    Correct Answer
    C. Garbage value
    Explanation
    The output of the given C code will be "Network". The character array "arr" is initialized with the string "Network" which is 7 characters long. When the printf statement is executed, it will print the string stored in the "arr" array. Therefore, the output will be "Network" and not garbage value.

    Rate this question:

  • 8. 

    #include<stdio.h> int main(){  const int i=5;  i++;  printf("%d",i); return 0; }

    • A.

      5

    • B.

      6

    • C.

      0

    • D.

      Compiler error

    • E.

      None of above

    Correct Answer
    D. Compiler error
    Explanation
    The given code will result in a compiler error. This is because the variable "i" is declared as a constant using the "const" keyword, which means its value cannot be changed. However, in the code, there is an attempt to increment the value of "i" using the "i++" statement, which is not allowed for a constant variable. Therefore, the code will not compile successfully.

    Rate this question:

  • 9. 

    #include<stdio.h> int main() { int i = 1; switch(i) { printf("Hello\n"); case 1: printf("Hi\n"); break; case 2: printf("\nBye\n"); break; } return 0; }

    • A.

      Hello hi

    • B.

      Hello bye

    • C.

      Hi

    • D.

      Hi hello

    • E.

      Hello

    Correct Answer
    C. Hi
    Explanation
    The code provided will not compile successfully due to a syntax error. The printf statement "Hello" is placed outside of any case block, which is not allowed in a switch statement. Therefore, the code will produce a compilation error.

    Rate this question:

  • 10. 

    # include<stdio.h> # define a 10 void foo(); main() {    printf("%d..",a);    foo();    printf("%d",a); } void foo() {    #undef a    #define a 50 }

    • A.

      10..10

    • B.

      10..50

    • C.

      Error

    • D.

      0

    • E.

      Compilation error

    Correct Answer
    A. 10..10
    Explanation
    The code first defines a constant variable "a" with a value of 10 using the "#define" directive. It then calls the "foo()" function, which undefines the previous definition of "a" and redefines it with a new value of 50. However, since the "foo()" function is called after the first printf statement, the first printf statement will still print the original value of "a", which is 10. Therefore, the output will be "10..10".

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 04, 2011
    Quiz Created by
    Shamil
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.