Variables in C Programming

Last Updated :
Discuss
Comments

Question 1

What is a variable in C?

  • A

    A fixed value

  • B

    A memory location to store data

  • C

    A keyword

  • D

    A preprocessor directive


Question 2

Which of the following is the correct way to declare an integer variable in C?

  • A

    x int;

  • B

    int x;

  • C

    integer x;

  • D

    x = int;

Question 3

What is the default value of a local variable in C?

  • A

    0

  • B

    Garbage Value

  • C

    NULL

  • D

    Undefined

Question 4

What is the scope of a variable declared inside a function?

  • A

    Global

  • B

    Block

  • C

    Function

  • D

    File

Question 5

Which data type would you use to store a single character in C?

  • A

    int

  • B

    char

  • C

    string

  • D

    float

Question 6

Which of the following statements is true about global variables?

  • A

    They are only accessible inside one function

  • B

    Their lifetime ends after the function ends

  • C

    They are declared inside main()

  • D

    They are accessible throughout the program

Question 7

What happens if you use an undeclared variable in C?

  • A

    It gets initialized to 0

  • B

    Program runs with a warning

  • C

    The compiler assigns memory automatically

  • D

    Compilation error

Question 8

What will be the value of a in the end?

C
int a = 5;
int b = a;
b = 10;


  • A

    5

  • B

    10

  • C

    0

  • D

    Garbage Value

Question 9

Which variable will have the highest scope?

  • A

    Variable declared inside a loop

  • B

    Variable declared inside a function

  • C

    Static variable

  • D

    Global variable

Question 10

Which keyword tells the compiler to look for a variable’s definition elsewhere?

  • A

    extern

  • B

    static

  • C

    register

  • D

    const

There are 13 questions to complete.

Take a part in the ongoing discussion