Defination: Data types in c refer to an extensive system used for declaring variables or functions of different types.
The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.
-----------------------------------------------------------------------------------------
Technical and Interview asked questions for placement in c programming language
-----------------------------------------------------------------------------------------
1.
Consider on following declaration in c:
(i) short const register i=10;
(ii) static volatile const int i=10;
(iii) signed extern float i=10.0;
(iv) unsigned auto long register i=10;
Choose correct one:
A. | Only (iv)is correct | |
B. | Only (ii) and (iv) is correct | |
C. | Only (i) and (ii) is correct | |
D. | Only (iii) correct | |
E. | All are correct declaration |
Answer: C
-----------------------------------------------------------------------------------------
2.
Which of the following is a User-defined data type?
A. typedef int Boolean;
B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C. struct {char name[10], int age};
D. All of the mentioned
Answer: D
Explanation:
typedef and struct are used to define user-defined data types.
-----------------------------------------------------------------------------------------
3.
Comment on the output of this C code?
int main()
{ int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
}
A. The compiler will flag an error
B. Program will compile and print the output 5
C. Program will compile and print the ASCII value of 5
D. Program will compile and print FAIL for 5 times
Answer: D
Explanation:
The ASCII value of 5 is 53,
the char type-casted integral value 5 is 5 only.
Output: $ cc pgm1.c
$ a.out
FAILED
FAILED
FAILED
FAILED
FAILED
-----------------------------------------------------------------------------------------
4.
Which of the following is a User-defined data type?
A. typedef int Boolean;
B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
C. struct {char name[10], int age};
D. All of the mentioned
Answer: D
Explanation:
typedef and struct are used to define user-defined data types.
-----------------------------------------------------------------------------------------
5.
What is the size of an int data type?
A. 4 Bytes
B. 8 Bytes
C. Depends on the system/compiler
D. Cannot be determined.
Answer: C
Explanation:
The size of the data types depend on the system.
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
More Imp Topics