C Programming Quiz [bcqs]

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 Harshit Panwar
H
Harshit Panwar
Community Contributor
Quizzes Created: 1 | Total Attempts: 98
Questions: 30 | Attempts: 98

SettingsSettingsSettings
C Programming Quiz [bcqs] - Quiz

.


Questions and Answers
  • 1. 

    Who is the father of C programming?

    • A.

      Dennis Ritchie

    • B.

      Linus Torvalds

    • C.

      Charles Babbage

    • D.

      Bill Gates

    Correct Answer
    A. Dennis Ritchie
    Explanation
    Dennis Ritche - inventor of C programming language and co-developer of Unix;    Linus Torvalds - developed a Unix-like operating system, LINUX;    Charles Babbage - father of Computer;    Bill Gates - co-founder of Microsoft Corporation;

    Rate this question:

  • 2. 

    Which of the following is a C language compiler?

    • A.

      AutoCAD

    • B.

      Adobe Acrobat

    • C.

      Turbo C/C++

    • D.

      MS Powerpoint

    Correct Answer
    C. Turbo C/C++
    Explanation
    AutoCAD - Computer-aided Designing of Electrical/Electronics circuit and Civil/mechanical models;      Adobe Acrobat - view, create, manipulate, print and manage files in Portable Document Format;     Turbo C/C++ - Compiler for C and C++ program;    MS Powerpoint - Used for presenting Presentation by using wide variety of effects and animations

    Rate this question:

  • 3. 

    C uses a:-

    • A.

      Compiler

    • B.

      Interpreter

    Correct Answer
    A. Compiler
    Explanation
    Compiler - transforms code written in a high-level programming language into the machine code, at once, before program runs. Interpreter - coverts each high-level program statement, one by one, into the machine code, during program run.

    Rate this question:

  • 4. 

    Which choice indicates a single-line comment?

    • A.

      **single line comment

    • B.

      //single line comment

    • C.

      ##single line comment

    Correct Answer
    B. //single line comment
    Explanation
    The correct answer is "//single line comment" because in many programming languages, including C++, Java, and Python, the double forward slash "//" is used to indicate a single-line comment. This means that any text written after "//" on the same line is ignored by the compiler or interpreter. In contrast, "##" is typically used for comments in some scripting languages like Perl, while "#single line comment" would be interpreted as a regular line of code.

    Rate this question:

  • 5. 

    Which function copies one string over another

    • A.

      Strcat()

    • B.

      Strcmp()

    • C.

      Strcpy()

    • D.

      Strlen()

    Correct Answer
    C. Strcpy()
    Explanation
    strcat() is used to append or join two strings. strcmp() is used to compare two strings. strcpy() is used to copy one string over another. strlen() is used to get the length of the string.

    Rate this question:

  • 6. 

    C programs must have at least one function named main():

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    C programs must have at least one function named main() because the main() function is the entry point of the program. It is where the program starts executing and from where other functions can be called. Without a main() function, the program would not have a starting point and therefore cannot be executed.

    Rate this question:

  • 7. 

    How many times does the following loop run? for(int i=0;i<5;i++) {statement;}

    • A.

      4

    • B.

      6

    • C.

      5

    • D.

      None of the above

    Correct Answer
    C. 5
    Explanation
    1) :- i=0;    2) :- i=1;    3) :- i=2;    4) :- i=3;     5) :- i=4;    6th time 5<5 : which is false. Therefore, it exits the loop

    Rate this question:

  • 8. 

    Importing "math" header file lets the user use

    • A.

      Sqrt()

    • B.

      Getch()

    • C.

      Printf()

    • D.

      Clrscr()

    Correct Answer
    A. Sqrt()
    Explanation
    sqrt() which finds square root of the argument can be used after importing math header file. getch() which fetches a single char from user and clrscr() clears the output screen, they can be used after importing conio header file. printf() which prints the argument in output screen can be used after importing stdio header file.

    Rate this question:

  • 9. 

    What does "static" variable storage class does?

    • A.

      Allows the variable to change its value only by addition/subtraction

    • B.

      Doesn't allow the variable to change it's value throughout the program

    • C.

      Allows the variable to change its value only two times

    • D.

      Allows the variable to change its value while in loop

    Correct Answer
    B. Doesn't allow the variable to change it's value throughout the program
    Explanation
    The "static" variable storage class doesn't allow the variable to change its value throughout the program. Once a static variable is initialized, its value remains the same until the program terminates. This is because static variables are allocated memory only once and retain their values between function calls. They are commonly used when a variable needs to maintain its value across multiple function calls or when we want to limit the scope of a variable to a specific function.

    Rate this question:

  • 10. 

    What is the function of "#define"

    • A.

      Value cannot be changed by your program code

    • B.

      Imports the specified library

    • C.

      Inserts a title to the file in output window

    Correct Answer
    A. Value cannot be changed by your program code
    Explanation
    The function of "#define" is to create a constant value that cannot be changed by the program code. This allows the programmer to define a value once and use it throughout the program without the risk of accidentally modifying it. It is commonly used for defining constants such as mathematical values or configuration settings.

    Rate this question:

  • 11. 

    What is the output of the following program? #include main() {     int x,y,z=0;    //float y;        y = 3;    x = 7;    y+=2;    z=y+x;    printf("x=%d z=%d", x, z); }

    • A.

      7 12

    • B.

      7 5

    • C.

      5 12

    • D.

      Syntax Error

    Correct Answer
    A. 7 12
    Explanation
    The program initializes three variables: x, y, and z. The value of y is set to 3 and the value of x is set to 7. Then, y is incremented by 2, resulting in a value of 5. Finally, z is assigned the sum of y and x, which is 5 + 7 = 12. The printf statement prints the values of x and z, which are 7 and 12 respectively.

    Rate this question:

  • 12. 

    Which of the following are not a keyword? [One or more options correct]

    • A.

      Break

    • B.

      Java

    • C.

      Help

    • D.

      Float

    Correct Answer(s)
    B. Java
    C. Help
    Explanation
    The keywords in programming languages are reserved words that have a specific meaning and cannot be used as identifiers. In this case, "java" is not a keyword because it can be used as an identifier for variables, classes, or methods. Similarly, "help" is also not a keyword as it can be used as an identifier. However, "break" and "float" are keywords in Java and cannot be used as identifiers.

    Rate this question:

  • 13. 

    Which of the following is a relational operator?

    • A.

      =!

    • B.

      !=

    • C.

      =>

    • D.

      ++

    Correct Answer
    B. !=
    Explanation
    The correct answer is !=. This is a relational operator used to check if two values are not equal to each other. It returns true if the values are not equal, and false if they are equal.

    Rate this question:

  • 14. 

    What is the output of the following program? #include main() {     int x;    float y;        y = x = 7.5;    printf("x=%d y=%f", x, y); }

    • A.

      X=7 y=7.000000

    • B.

      X=7 y=7.500000

    • C.

      X=5 y=7.500000

    • D.

      X=5 y=5.000000

    Correct Answer
    A. X=7 y=7.000000
    Explanation
    ‘x’ gets the integral value from 7.5 which is 7 and then 'y' get the value from 'x' which is now 7. 'x' gets 7 instead of 7.5 because 'x' is an integer. y gets the value of 'x' which is 7. Since, 'y' is float, y=7.000000 Therefore, x=7 y=7.000000

    Rate this question:

  • 15. 

    The ________ operator is used with a pointer to de-reference the address contained in the pointer.

    Correct Answer
    *
    Explanation
    The * operator is used with a pointer to de-reference the address contained in the pointer. This means that it allows access to the value stored at the memory address pointed to by the pointer. By using the * operator, we can retrieve the value stored at that address and manipulate it as needed.

    Rate this question:

  • 16. 

    What will be the output of the following c program? #include int main(){ int goto=5; printf("%d",goto); return 0; }

    • A.

      5

    • B.

      **

    • C.

      Compilation error

    • D.

      None of these

    Correct Answer
    C. Compilation error
    Explanation
    Compilation error.    Invalid variable name. goto is keyword in c. variable name cannot be any keyword of c language.

    Rate this question:

  • 17. 

    Which of the following statement is incorrect?

    • A.

      Every variable name should start with alphabets or underscore.

    • B.

      No spaces are allowed in variable declaration.

    • C.

      Except underscore and ampersand no other special symbol are allowed in the middle of the variable declaration.

    • D.

      Variable name must not start with a digit.

    • E.

      Keywords are not allowed as variable name.

    Correct Answer
    C. Except underscore and ampersand no other special symbol are allowed in the middle of the variable declaration.
    Explanation
    Ampersand(&) is not allowed to be used in variable name.

    Rate this question:

  • 18. 

    Count the total number of errors(if any):- #include<stdio.h> int main(){     int i;     for(i=0;i=<5;i++);         printf("%d",i)     return 0; }

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      3

    • E.

      4

    • F.

      5

    • G.

      6

    Correct Answer
    D. 3
    Explanation
    3 errors.  [1]relational operator in condition should be <= instead of =< [2]after 'for' statement semi-colon(;) is present [3]after print statement semi-colon isn't present

    Rate this question:

  • 19. 

    An array can be initialized at either compile time or at ________

    Correct Answer
    runtime, run time
    Explanation
    An array can be initialized at either compile time or at runtime. This means that the array can be assigned values either when the program is being compiled or during the execution of the program. The choice of when to initialize the array depends on the specific requirements and needs of the program.

    Rate this question:

  • 20. 

    When initializing a multidimensional array, not specifying all its dimensions is an error.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    When initializing a multidimensional array, it is necessary to specify all its dimensions. If any dimension is not specified, it will result in an error. This is because each dimension represents a specific level of the array, and not specifying a dimension would create ambiguity in the array's structure. Therefore, it is important to provide the correct number of dimensions and their sizes when initializing a multidimensional array.

    Rate this question:

  • 21. 

    Which loop executes the statement within the loop at least one time? [One or more options may be correct]

    • A.

      For loop

    • B.

      Do...while loop

    • C.

      While loop

    Correct Answer
    B. Do...while loop
    Explanation
    do...while
    As the condition is checked at the end of the loop, it is also know as exit-controlled loop.

    Rate this question:

  • 22. 

    The C standard function that receives a single character from the keyboard is ________

    Correct Answer
    getch,getch(),getchar,getchar()
    Explanation
    The C standard function that receives a single character from the keyboard is either getch or getchar. Both functions can be used to read a single character from the keyboard, with getch being a non-standard function and getchar being a standard function. The use of parentheses after the function name (getch() or getchar()) is optional.

    Rate this question:

  • 23. 

    The expression !(x<=y) is same as the expression x>y.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The expression !(x

    Rate this question:

  • 24. 

    )What would be the output of the program:- #include main() {    int a[] = {2,1};    printf("%d", a[1]); }

    • A.

      2

    • B.

      1

    • C.

      0

    • D.

      Compile Error

    Correct Answer
    B. 1
    Explanation
    1
    The index value of array a over here is '1'
    The first element has index value '0' and the second element has index value '1'.
    Therefore, a[1]=1

    Rate this question:

  • 25. 

    Can we replace any "switch" statement with "if..else" statement?

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    Explanation
    Yes, we can replace any "switch" statement with an "if..else" statement. Both "switch" and "if..else" statements are used for making decisions based on certain conditions. The "switch" statement allows multiple conditions to be checked, while the "if..else" statement allows for more complex conditions and multiple conditions to be checked as well. Therefore, it is possible to replace a "switch" statement with an equivalent "if..else" statement.

    Rate this question:

  • 26. 

    Can we replace any "if..else" statement with "switch" statement?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    Explanation
    No

    For instance,

    "if (a>0 && a

    Rate this question:

  • 27. 

    Find the output of the following program:- #include main() {    int i = 1;        while(++i <= 5)       printf("%d ",++i); } Enter the output here ________

    Correct Answer
    3 5,35
    Explanation
    3 5

    | i | ++i | i

    Rate this question:

  • 28. 

    Find the output of the following program:- #include int main() {     static int i = 10;     auto int x = i;     if (x==i)         printf("x and i are Equal\n");     else         printf("x and i are Unequal\n");     return 0; } Enter the output here ________

    Correct Answer
    x and i are Equal
    Explanation
    Variable Storage Classes:-
    static is declared then the value of the variable doesn't change during runtime whereas auto lets the value change during runtime.
    Since there is no operation that is trying to change the value of the variables so, it's just a comparison of both the variables.

    Rate this question:

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.