Data Types in C Language MCQ Questions

Data Types in C Language MCQ Questions

Data Types in C MCQs is one of the largest searchable categories across the world. keep reading and practicing for tests, exams, and interviews for professional fields. there are thousands of selected questions with answers. C Language History MCQs

Most Important Keywords searched in Google: variables, independent variable, dependent variable, data types, data types in python, SQL data types, endogenous, confounding variable, variable meaning, controlled variable, positive correlation, find the value of x, extraneous variable, explanatory variable, discrete variable, independent variable example, continuous variable, expected value, independent and dependent variables, data types in c, data types in java, abstract data type, primitive data types, primitive data types in Java, MySQL data types, javascript data types, float data type, data types in c++, Postgres data types, boolean data type, Data Types in C

How many keywords are there in c?

A. 31
B. 32
C. 64
D. 63

Answer
B

Keywords are predefined, reserved words in the C language and each of which is associated with specific features. These words help us to use the functionality of the C language. They have special meaning to the compilers. There are a total of 32 keywords in C

 

Which of the following is true for variable names in C?

A. Variable names cannot start with a digit
B. Variable can be of any length
C. They can contain alphanumeric characters as well as special characters
D. Reserved Word can be used as a variable name

Answer
A

Variable names cannot start with a digit in the C Programming language.

 

Which of the following cannot be a variable name in C?

A. TRUE
B. friend
C. export
D. volatile

Answer
D

volatile is C keyword.Volatile in C programming language signify that the compiler that the software in hand (the thread for the routine it’s compiling) doesn’t have exclusive control over the variable described as “volatile”

 

What is the output of this program?

void main()
{
int x = 10;
float x = 10;
printf("%d", x)
}

A. Compilations Error
B. 10
C. 10
D. 10.1

Answer
A

Since the variable x is defined both as integer and as float, it results in an error.

 

What is the output of this program?

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

A. Syntax error in the declaration of a
B. No errors, program will show the output 5
C. Redeclaration of an in same scope throws an error
D. a is out of scope when printf is called

Answer
A

the output of this program is the Syntax error in the declaration of variable a.

 

What is the output of this program?

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

A. Garbage Value
B. 20
C. Compiler Error
D. None of these

Answer
A

First, var is declared, then the value is assigned to it. As soon as var is declared as a local variable, it hides the global variable var.

 

What is the size of int in C?

A. 2 bytes
B. 4 bytes
C. 8 bytes
D. Depends on the system/compiler

Answer
D

The size of the data types depends on the system. The size of “int”, in fact, every other data type as well is compiler dependent and not language-dependent. Based on how a compiler is implemented, it can take either 2 bytes or 4 bytes.

 

Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform – Turbo C under DOS)

A. TRUE
B. FALSE
C. May Be
D. Can’t Say

Answer
B

The range of double is -1.7e+308 to 1.7e+308.

 

Which is false?

A. Constant variables need not be defined as they are declared and can be defined later
B. Global constant variables are initialized to zero
C. const keyword is used to define constant values
D. You cannot reassign a value to a constant variable

Answer
A

Since the constant variable has to be declared and defined at the same time, not doing it results in an error..

 

Array is ______ datatype in C Programming language.

A. Derived Data type
B. Primitive Data type
C. Custom Data type
D. None of these

Answer
A

Data types simply refer to the type and size of data associated with variables and functions. It is of two types:- Fundamental Data Types and Derived Data Types. The array is Derived Data type datatype in C Programming language.

 

If you pass an array as an argument to a function, what actually gets passed?

A. Address of last element of Array
B. Value of first element
C. Base address of array
D. Value of elements in array

Answer
C

Base address of array is passed.

 

When double is converted to float, the value is?

A. Rounded
B. Truncated
C. Depends on the standard
D. Depends on the compiler

Answer
D

When double is converted to float, the value will be Depends on the compiler.

 

Which of the following is not a logical operator?

A. !
B. &&
C. ||
D. |

Answer
D

&& – Logical AND ! – Logical NOT || – Logical OR | – Bitwise OR(used in bitwise manipulations)

 

What is the output of this program?

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

A. 0
B. 1
C. -1
D. NULL

Answer
C

EOF is macro which has been defined in the studio. h and it is equivalent to -1.

 

Which of the following can have different meanings in different contexts?

A. &
B. *
C. Both A and B
D. None of the above

Answer
A

& have different meaning in different contexts.

 

Which of the following is not a valid declaration in C?
1. short int x;   Â
2. signed short x;
3. short x;
4. unsigned short x;

A. 1 and 2
B. 2 and 4
C. 3 and 4
D. All are valid

Answer
D

All are valid. The First 3 mean the same thing. 4th means unsigned.

 

The minimum number of temporary variables needed to swap the content two variables is?

A. 2
B. 3
C. 0
D. 1

Answer
C

Without any temporary variable ,one can swap two variables easily. For Example :- var a ,b; a=a+b; b=a-b; a=a-b;

 

What is short int in C programming?

A. The basic data type of C
B. Qualifier
C. Short is the qualifier and int is the basic datatype
D. All of the mentioned

Answer
C

short is the qualifier and int is the basic datatype.

 

The precedence of arithmetic operators is (from highest to lowest)?

A. %, *, /, +, –
B. %, +, /, *, –
C. %, +, -, *, /
D. +, -, %, *, /

Answer
A

All arithmetic operators in C language follow the left to right associativity. Their precedence from highest to lowest is as given below: () => Brackets % => Modulus * => Multiplication / => Division + => Addition – => Subtraction In an arithmetic operation, the higher precedence operators are evaluated first followed by the lower value operators.

 

Which of the following data type will throw an error on modulus operation(%)?

A. int
B. char
C. float
D. long

Answer
C

Float data type will throw an error on modulus operation(%).

 

Relational operators cannot be used on:

A. String
B. float
C. long
D. structure

Answer
D

structure cannot be used on Relational operators.

 

By default, a real number is treated as a

A. float
B. double
C. long double
D. far double

Answer
B

A double is a more accurate way of representing floating-point numbers due to more digits of precision and defaulting to a double for constants will yield more accurate and consistent answers.

 

How would you round off a value from 6.66 to 7.0?

A. ceil(6.66)
B. floor(6.66)
C. roundup(6.66)
D. roundto(6.66)

Answer
A

The ceil function returns the smallest integer that is greater than or equal to x.

 

The format identifier %i is also used for _____ data type?

A. char
B. int
C. float
D. double

Answer
B

Both %d and %i can be used as a format identifier for int data type.

 

Variable names beginning with an underscore are not encouraged. Why?

A. It is not standardized
B. To avoid conflicts since assemblers and loaders use such names
C. To avoid conflicts since library routines use such names
D. To avoid conflicts with environment variables of an operating system

Answer
C

To avoid conflicts since library routines use such names.

 

 

 

Leave a Reply