0

Data Types, Variables and Storage Classes

Description: Data types Variables and Storage Classes
Number of Questions: 20
Created by:
Tags: Data types Variables and Storage Classes Placement Papers Data Types Variables and Storage Classes
Attempted 0/20 Correct 0 Score 0

What will be the output of the following set of codes after execution? void main() { printf(“%d %d %d ”,56,056,0x56); }

  1. 56 56 56

  2. 56 056 56

  3. 56 46 86

  4. 56 56 86


Correct Option: C
Explanation:

%d specifier display the output in decimal number system. 56 is the decimal number, 056 is the octal number equivalent to 46 in decimal, 0x56 is the hexadecimal number equivalent to 86 in decimal. So, the output will be 56 46 86.

What will be the output of the following set of code after execution?

void main() { printf(“%c %d”,'C','C'); }

  1. C C

  2. 67 67

  3. C Garbage Value

  4. C 67


Correct Option: D
Explanation:

%c specifier prints C because 'C' is a character. But %d specifier prints 67 (ASCII value of C).

What will be the output of the following set of codes after execution?

void main() { int m=32769; unsigned int n=65540; printf(“%d %u”,m,n); }

  1. Garbage value

    • 32767 4
    • 32768 0
    • 32767 3

Correct Option: B
Explanation:

Range of int is -32768 to +32767. Value of m exceeds the limit of int. So after 32767, it goes to the other side of the range and 32769 will convert to -32767. Range of unsigned int is 0 to 65535. Value of n exceeds the limit of int. So after 65535, it goes to the other side of the range and 65535 will convert to 4.

What will be the output of the following set of code after execution?

void main() { float m=3.6e38; printf(“%f”,m); }

  1. +INF

    • INF
  2. 0.000000

  3. Garbage value


Correct Option: A
Explanation:

Range is not wraps around in case of float datatype. So, if float value is outside the range on +ve side, then output will be +INF (+ infinity).

Which one does not act as an identifier?

  1. Macro name

  2. User defined Function Name

  3. Keywords

  4. Variable name


Correct Option: C
Explanation:

Keywords cannot be identifier.

What will be the output of the following set of code after execution?

void main() { printf(“ABC +CDE”); }

  1. ABC +CDE

  2. ABC + CDE

  3. ABC CDE

  4. ABC +DE


Correct Option: A

Which of the following does not belong to basic data type?

  1. int

  2. float

  3. char

  4. short


Correct Option: D
Explanation:

'short' is the type modifier. Type modifier modifies the range and the properties of base type.

Which one is wrong with respect to variable name in C language?

  1. Variable name should start with alphabet.

  2. Variable name contains the space.

  3. Variable name should be different from the keywords.

  4. Variable name contains underscore(_).


Correct Option: B
Explanation:

Space is not allowed in variable name. For example, RollNum is valid and Roll Num is invalid variable name.

The C language was intended for

  1. running application software

  2. low level/system programming

  3. high level programming

  4. machine language programming


Correct Option: B
Explanation:

Initially C language was intended for the system programming. For example, UNIX operating system is written in C language.

Which format specifier is used for printing an unsigned integer in hexadecimal number system?

  1. %h

  2. %u

  3. %x

  4. %hd


Correct Option: C
Explanation:

%x is the format specifier, which is used for printing an unsigned integer in hexadecimal number system. %h is not a valid format specifier. %u is used for printing the unsigned integer in decimal number system. %hd is used for printing the signed short.

If C language uses two bytes of memory for storing the integer data type, what is the maximum value that an integer data type accommodates?

  1. 216

  2. 215-1

  3. 215

  4. 215+1


Correct Option: B
Explanation:

If any integer data type uses n bytes, then its maximum range will be 2(No of bits -1)-1. In this case, 2 Bytes = 16 bits 2(16-1) - 1 = 215-1=32768-1=32767

If there is a string constant “abcdefdgi”, how many bytes are required to store it in memory?

  1. 10

  2. 9

  3. 1

  4. 2


Correct Option: A
Explanation:

String constant uses 1 byte for each character and 1 byte for the null character at the end of the string. So, number of character in “abcdefdgi” is 9, and 1 null character is at the end of string, i.e. 10.

What will be the output of the following set of code after execution?

void main() { printf(“%d %d”,sizeof('9'),sizeof(567)); }

  1. 1 3

  2. 1 2

  3. 2 2

  4. 2 3


Correct Option: B
Explanation:

sizeof('9') gives 1 because '9' is a character not integer and sizeof(567) gives 2 because 567 is an integer.

Characteristics of variable in C language are:

  1. value and types of variable

  2. name and location in the memory

  3. its value can change during execution.

  4. all of these


Correct Option: D
Explanation:

All of these are the characteristics of Variable. Variables must have its name, data type and value. Without data type variables cannot be declared. Variables also have some location in memory. And variables' value can be changed during the execution of a program.

Which storage class declared the identifiers in the global scope?

  1. Auto

  2. Static

  3. Register

  4. Extern


Correct Option: D
Explanation:

The extern storage class declared the variable as an external variable, which can be accessed from any part of the program.

Which of the following is the default storage class in C language?

  1. Auto

  2. Static

  3. Register

  4. Extern


Correct Option: A
Explanation:

Auto is the default storage class in C language. For example: auto int num;  or int num; Both of the above statements are the same.

Which of the following is not the valid header file?

  1. stdio.h

  2. assert.h

  3. alloc.h

  4. malloc.h


Correct Option: D
Explanation:

stdio.h is used for the standard input/output. assert.h contains the assert(). alloc.h contains the malloc(), calloc(), realloc() etc. malloc.h is not a header file.

In C language, which is/are the derived data type(s)?

  1. Structure

  2. Function

  3. Array

  4. All of the above


Correct Option: D
Explanation:

All structure, function and arrays are the derived data types. Derived data types are derived from base data type.

How many keywords are there in C language?

  1. 32

  2. 64

  3. 42

  4. 52


Correct Option: A
Explanation:

There are 32 keywords in C language.

What will be the output of the following set of codes after execution?

void main() { printf(“%d”,sizeof(' ')); }

  1. 2

  2. 1

  3. 0

  4. Garbage value


Correct Option: B
Explanation:

It will print 1 because ' ' is a tab character. ' ' is the escape sequence and C language considers all escape sequence as a single character.

- Hide questions