C Language Quiz (Total Question : 57)
Q.1
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
A . rem = 3.14 % 2.1;
B . rem = modf(3.14, 2.1);
C . rem = fmod(3.14, 2.1);
D . Remainder cannot be obtain in floating point division.
Show Answer
Q.2
What are the types of linkages?
A . Internal and External
B . External, Internal and None
C . External and None
D . Internal
Show Answer
Q.3
Which of the following special symbol allowed in a variable name?
A . * (asterisk)
B . | (pipeline)
C . - (hyphen)
D . _ (underscore)
Show Answer
Q.4
Is there any difference between following declarations?
1 : extern int fun();
2 : int fun();
A . Both are identical
B . No difference, except extern int fun(); is probably in another file
C . int fun(); is overrided with extern int fun();
D . None of these
Show Answer
Q.5
How would you round off a value from 1.66 to 2.0?
A . ceil(1.66)
B . floor(1.66)
C . roundup(1.66)
D . roundto(1.66)
Show Answer
Q.6
By default a real number is treated as a
A . float
B . double
C . long double
D . far double
Show Answer
Q.7
When we mention the prototype of a function?
A . Defining
B . Declaring
C . Prototyping
D . Calling
Show Answer
Q.8
A long double can be used if range of a double is not enough to accommodate a real number.
A . True
B . False
Show Answer
Q.9
A float is 4 bytes wide, whereas a double is 8 bytes wide.
A . True
B . False
Show Answer
Q.10
If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function.
A . True
B . False
Show Answer
Q.11
How many times \"tutorial44\" is get printed?
#include<stdio.h>
int main()
{
int x;
for (x=-1 ; x<=10 ; x++)
{
if (x < 5 )
continue ;
else
break ;
printf(\"tutorial44\" );
}
return 0 ;
}
A . Infinite times
B . 11 times
C . 0 times
D . 10 times
Show Answer
Q.12
How many times the while loop will get executed if a short int is 2 byte wide?
#include<stdio.h>
int main()
{
int j=1 ;
while (j <= 255 )
{
printf(\"%c %d\\n\" , j, j);
j++;
}
return 0 ;
}
A . Infinite times
B . 255 times
C . 256 times
D . 254 times
Show Answer
Q.13
Which of the following is not logical operator?
A . &
B . &&
C . ||
D . !
Show Answer
Q.14
In mathematics and computer programming, which is the correct order of mathematical operators ?
A . Addition, Subtraction, Multiplication, Division
B . Division, Multiplication, Addition, Subtraction
C . Multiplication, Addition, Division, Subtraction
D . Addition, Division, Modulus, Subtraction
Show Answer
Q.15
Which of the following cannot be checked in a switch-case statement?
A . Character
B . Integer
C . Float
D . enum
Show Answer
Q.16
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=0 ;
for (; i<=5 ; i++);
printf(\"%d\" , i);
return 0 ;
}
A . 0, 1, 2, 3, 4, 5
B . 1, 2, 3, 4
C . 6
D . 5
Show Answer
Q.17
What will be the output of the program?
#include<stdio.h>
int main()
{
unsigned int i = 65535 ;
while (i++ != 0 )
printf(\"%d\" ,++i);
printf(\"\\n\" );
return 0 ;
}
A . Infinite loop
B . 0 1 2 ... 32767 - 32766 -32765 -1 0
C . 0 1 2 ... 65535
D . No output
Show Answer
Q.18
A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.
A . True
B . False
Show Answer
Q.19
If scanf() is used to store a value in a char variable then along with the value a carriage return(\\r) also gets stored it.
A . True
B . False
Show Answer
Q.20
The modulus operator cannot be used with a long double.
A . True
B . False
Show Answer
Q.21
Which of the following correctly shows the hierarchy of arithmetic operations in C?
A . / + * -
B . * - / +
C . + - / *
D . / * + -
Show Answer
Q.22
The keyword used to transfer control from a function back to the calling function is
A . switch
B . goto
C . go back
D . return
Show Answer
Q.23
How many times the program will print "tutorial44" ? #include<stdio.h> int main(){ printf("tutorial44" ); main(); return 0 ;}
A . Infinite times
B . 42767 times
C . 75535 times
D . Till stack overflows
Show Answer
Q.24
A function cannot be defined inside another function
A . True
B . False
Show Answer
Q.25
Functions cannot return more than one value at a time
A . True
B . False
Show Answer
Q.26
If return type for a function is not specified, it defaults to int
A . True
B . False
Show Answer
Q.27
In C all functions except main() can be called recursively.
A . True
B . False
Show Answer
Q.28
Functions can be called either by value or reference
A . True
B . False
Show Answer
Q.29
Functions cannot return a floating point number
A . Yes
B . No
Show Answer
Q.30
Every function must return a value
A . Yes
B . No
Show Answer
Q.31
What is (void*)0?
A . Representation of NULL pointer
B . Representation of void pointer
C . Error
D . None of above
Show Answer
Q.32
In which header file is the NULL macro defined?
A . stdio.h
B . stddef.h
C . stdio.h and stddef.h
D . math.h
Show Answer
Q.33
How many bytes are occupied by near, far and huge pointers (DOS)?
A . near=2 far=4 huge=4
B . near=4 far=8 huge=8
C . near=2 far=4 huge=8
D . near=4 far=4 huge=8
Show Answer
Q.34
Are the expression *ptr++ and ++*ptr are same?
A . True
B . False
Show Answer
Q.35
Are the three declarations char **apple, char *apple[], and char apple[][] same?
A . True
B . False
Show Answer
Q.36
What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
A . The element will be set to 0.
B . The compiler would report an error.
C . The program may crash if some important data gets overwritten
D . The array size would appropriately grow.
Show Answer
Q.37
How will you free the allocated memory ?
A . remove(var-name);
B . free(var-name);
C . delete(var-name);
D . dalloc(var-name);
Show Answer
Q.38
In C, if you pass an array as an argument to a function, what actually gets passed?
A . Value of elements in array
B . First element of the array
C . Address of the last element of array
D . Base address of the array
Show Answer
Q.39
A pointer to a block of memory is effectively same as an array
A . True
B . False
Show Answer
Q.40
Does this mentioning array name gives the base address in all the contexts?
A . Yes
B . No
Show Answer
Q.41
Are the expressions arr and &arr same for an array of 10 integers?
A . Yes
B . No
Show Answer
Q.42
What is the similarity between a structure, union and enumeration?
A . All of them let you define new values
B . All of them let you define new data types
C . All of them let you define new pointers
D . All of them let you define new structures
Show Answer
Q.43
Point out the error in the program?
struct emp
{
int ecode;
struct emp *e;
};
A . Error: in structure declaration
B . Linker Error
C . No Error
D . None of above
Show Answer
Q.44
A union cannot be nested in a structure
A . True
B . False
Show Answer
Q.45
Nested unions are allowed
A . True
B . False
Show Answer
Q.46
one of elements of a structure can be a pointer to the same structure.
A . True
B . False
Show Answer
Q.47
A structure can be nested inside another structure.
A . True
B . False
Show Answer
Q.48
size of union is size of the longest element in the union
A . Yes
B . No
Show Answer
Q.49
The elements of union are always accessed using & operator
A . Yes
B . No
Show Answer
Q.50
A pointer union CANNOT be created
A . Yes
B . No
Show Answer
Q.51
A function returns a value, whereas a subroutine cannot return a value.
A . True
B . False
Show Answer
Q.52
How many values is a subroutine capable of returning?
A . Depends upon how many params arguments does it use.
B . Any number of values.
C . Depends upon how many ref arguments does it use.
D . 0
Show Answer
Q.53
Which of the following CANNOT occur multiple number of times in a program?
A . namespace
B . Entrypoint
C . Class
D . Function
Show Answer
Q.54
A function can be used in an expression, whereas a subroutine cannot be.
A . True
B . False
Show Answer
Q.55
The this reference gets created when a member function (non-shared) of a class is called.
A . True
B . False
Show Answer
Q.56
Which of the following statements is correct about classes and objects in C#.NET?
A . Class is a value type.
B . Since objects are typically big in size, they are created on the stack.
C . Objects of smaller size are created on the heap.
D . Objects are always nameless.
Show Answer
Q.57
Can static procedures access instance data?
A . Yes
B . No
Show Answer