Quiz on Identifiers and Data Types in C

Quiz on Identifiers and Data Types in C | The Identifier is the name of the basic programming element. In other words, an identifier or name is a sequence of characters invented by the programmer to identify or name a specific object. A keyword that is used for creating variables for storing single and multiple values is called data types. Recommended Reading:- Constants, Identifiers, and Keywords, Data types in C language

Identifiers and Data Types Quiz in C

Q1) What will be the output of below C program?

#include<stdio.h>
int main()
{
  int abcdefghijkl0123456789 = 9;
  printf("%d", abcdefghijkl0123456789);
  return 0;
}

a) 0
b) Garbage Value
c) Compile-time error
d) 9


Ans:- d) 9

There is no limitation on identifier length but it is advisable to keep length only up to 32 characters.


Q2) Find the output of the given program?

#include<stdio.h>
int main()
{
  int π = 3.14;
  printf("%d",π);
  return 0;
}

a) Compile-time error
b) None of these
c) 3
d) 3.14


Ans:- a) Compile-time error

π is a special character, and it is not allowed as an identifier.


Q3) Find the output of the given program?

#include< stdio.h>
int main()
{
  const float pi = 3.14;
  pi = 3.14;
  printf("%d", pi);
  return 0;
}

a) Compile-time error
b) None of these
c) 3
d) 3.14


Ans:- a) Compile-time error

Const variable is only for reading. We can’t modify the value of constant variable.


Q4) What is the output of the given below program?

#include<stdio.h>
int main()
{
  int a = 10;
  float a = 1.1;
  printf("%d", a);
  return 0;
}

a) 10
b) 1.1
c) Compile-time error
d) 1


Ans:- c) Compile-time error

Duplicate identifiers are not allowed.


Q5) Find the output of the given program?

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

Ans:- d) A = 10

The identifiers are case sensitive.


Q6) Find the output of the below program?

#include<stdio.h>
int main()
{
  const float pi;
  pi = 3.14;
  printf("%f",pi);
  return 0;
}

a) 0
b) 3.14
c) 3
d) Compile-time error


Ans:- d) Compile-time error

We can’t modify the constant variable value after declaration. The constant variable should be initialized at the declaration time. If a constant variable is not initialized then it holds the default value of its data type.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *