loader image

Fundamentals of C Programming- MCQ

Here are the most important Multiple choice questions(MCQ) on the basics of C programming. The MCQs are from the following sections,

  • Introduction to C
  • Data types
  • Variables
  • Constants

  1. Who invented C?
    1. Charles Babbage
    2. Bill Gates
    3. Dennis Ritchie
    4. Steve Jobs
Show Answer

  1. C is a …………………. type of language?
    1. Procedural
    2. Object-oriented
    3. Functional
    4. Bit-level
Show Answer

  1. Which of the following is not a valid variable name declaration in C?
    1. int Mark_1;
    2. int mark1;
    3. int __mark1;
    4. int 1mark;
Show Answer

  1. Find the output of the following C code?
    1. Hello world a
    2. Hello world 0
    3. Hello world followed by a random value
    4. Compile-time error
#include <stdio.h>
int main() {
    printf("Hello world %d", a);
    return 0;
}
Show Answer

  1. Which of the following is not a valid variable name in C?
    1. mark
    2. number_1
    3. _count
    4. cash_$
Show Answer

  1. Which of the statement is true for naming variables in C?
    1. Variable names can be made up of alphabets, digits, and special characters.
    2. Variable names can begin with a digit.
    3. White spaces are not allowed in variable names.
    4. Variable names cannot contain the underscore character.
Show Answer

  1. What will be the output of the following C code?
    1. Hello World 100
    2. Hello World 25
    3. Hello World followed by a random number
    4. Compile-time error
#include <stdio.h>
int main()
{
    int x = 100;
    int x = 25;
    printf("Hello World %d", y);
    return 0;
}
Show Answer

  1. Which of the following cannot be a variable name in C?
    1. marks_1
    2. teacher
    3. SCORE
    4. for
Show Answer

  1. Determine the output of the following C code?
    1. 1147
    2. 1185
    3. Run time error
    4. Compile-time error
#include <stdio.h>
    int main()
    {
        int total_Marks = 1185;
        int total_marks = 1147;
        printf("%d", total_marks);
        return 0;
    }
Show Answer

  1. The format identifier “%d” is used for …………………. datatype?
    1. int
    2. char
    3. long
    4. float
Show Answer

  1. Which is the correct order of data types with respect to their size?
    1. int > char > float
    2. char > int > float
    3. char < double < int
    4. char < int < double
Show Answer

  1. Which of the following datatype has varying sizes?
    1. int
    2. double
    3. float
    4. struct
Show Answer

  1. Which of the following is not a data type in C?
    1. int
    2. real
    3. float
    4. char
Show Answer

  1. Which of the following statement is true?
    1. ANSI C treats the variable ‘name’ and ‘Name’ to be the same.
    2. Character constants are coded using double-quotes.
    3. All variables must be given a type when they are declared.
    4. Any valid printable ANSII character can be used in an identifier.
Show Answer

  1. What will be the output of the following C code?
    1. pi is 3.14
    2. Compile-time error
    3. pi is followed by a random value
    4. Run time error
#include <stdio.h>
    int main()
    {
        const float pi;
        pi = 3.14;
        printf("pi is %f", pi);
        return 0;
    }
Show Answer

  1. A global variable is also known as …………………. variable.
    1. external
    2. internal
    3. static
    4. dynamic
Show Answer

  1. Which of the following statement is true?
    1. Every line in a C program should end with a semicolon.
    2. Every C program ends with an END word.
    3. Comments cause the computer to print the text enclosed between /* and */ when executed.
    4. printf statement can generate only one line of output
Show Answer

  1. Identify the correct output for the following C code?
    1. Compile-time error.
    2. 8
    3. 8.0000000
    4. Garbage value
 #include <stdio.h>
void main()
{
    int a = 8;
    float a = 8;
    printf("%d", a);
}
Show Answer

  1. Which of the following declaration is not supported in C?
    1. String str;
    2. int a;
    3. float pi=3.14;
    4. char *str;
Show Answer

  1. If an integer needs two bytes of storage, then the maximum value of an unsigned integer is
    1. 2^{16} - 1
    2. 2^{15} - 1
    3. 2^{16}
    4. 2^{15}
Show Answer

  1. If an integer needs two bytes of storage, then the maximum value of a signed integer is
    1. 2^{16} - 1
    1. 2^{15} - 1
    1. 2^{16}
    1. 2^{15}
Show Answer

  1. The statement, printf("%d",printf("hello"));
    1. results in a syntax error
    2. outputs hello5
    3. outputs garbage
    4. prints hello and terminates
Show Answer

  1. What will be the output of the following fragment of code if the input is abc,
    1. Syntax error
    2. Fatal error
    3. 3
    4. none of the above
#include <stdio.h>
int main() {
    char x, y, z;
    printf ("%d", scanf("%c%c%c", &x, &y, &z ));
    return 0;
}
Show Answer

  1. Choose the correct statements.
    1. An identifier may start with an underscore
    2. An identifier may end with an underscore
    3. IF is a valid identifier
    4. All of above
Show Answer

  1. Which of the following are not keywords in C? :
    1. printf
    2. main
    3. IF
    4. All of above
Show Answer

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to Top