Thursday, July 29, 2010
C Question Set 1-7
Question 1
'C' is a
machine language
low level language
middle level language
high level language
Question 2
What is the error in the program?
char count;
main()
{
int count = 70;
{
extern int count;
printf("\n %d ", count);
}
}
Error: Type mismatch in redeclaration of ' nn'
Error: Multiple declaration for 'nn'
Error: Storage class 'extern' is not allowed here
Linker Error: Undefined symbol 'nn'
Question 3
What is the output of the program?
void main()
{
int val = (5, val = 5)/++val;
printf("\n %d ", val);
}
5
1
6
0
Question 4
Which of the following statements is used to return more than one value from a function?
return 1,2,3 ;
return (1,2,3) ;
return ((1), (2), (3));
None of the above
Question 5
Which of the following is wrong with respect to structures?
Having the same name for a structure and its variable
It has functions as its data members
It has a data member, which is of the same structure kind
Both B and C
Question 6
What is the error in the code shown below?
union
{
int val1 : 5;
char val2;
};
Declaration of variables is not possible due to the absence of tag name
Arrays of this union cannot be created
Cannot be used in file handling
All the three B, C and D
Question 7
What is an '&' operator?
logical
unary
bitwise
ternary
Question 8
What is the difference between malloc and calloc?
in allocation of memory
in return types
number of arguments
None of the above
Question 9
What is the default promotion for 'float' in va_arg?
double
int
long int
char
Question 10
What is the error in the program?
main()
{
int a = 12;
int *ptr = &a;
printf( " %d %d ", *ptr /*ptr, *ptr**ptr);
}
No error, output is 1 144
No error, output is 144 144
Unexpected end of file found
Error: illegal pointer operation
Question 11
What is the significance of the function realloc()?
realloc() adjusts the size of the allocated block to specified size
realloc() allocates memory on far heap
It is used to allocate more than 64k bytes
realloc() allocates the specified number of bytes in registers
Question 12
What is the error in the program?
main()
{
typedef struct personal
{
int name[25]:15;
}
personal; personal person;
}
Error: Bit fields must be signed or unsigned int
Error: Multiple declaration for 'personal'
Error: Undefined symbol 'personal'
Error: Size of the type is unknown or zero
Question 13
What is the return type of fflush()?
void
FILE*
char*
int
Question 14
What is the error in the program?
void myprintf()
{
printf("\n %d ", printf("Genesis"));
}
main() {
printf("\n %d ", myprintf());
}
Error: Type mismatch in 'printf'
The return type of a function must be an integer
Error: printf cannot return anything
Cannot convert from 'void' to '...'
Question 15
What is the meaning of a static function?
It is local to a file in which it is declared
It is local to main()
The set of variables used in the function is 'static'
All the linked files can access it
Question 16
What is the output of the program?
# include <stdio.h>
void main()
{
int main = 90;
top : printf("Label1");
if(main)
goto top;
}
Infinite
Label1
No output
label top is invalid
Question 17
How many times is the 'for' loop/statement is executed in the following code.
main()
{
unsigned char ch;
for(ch = 0; ch <= 255; ch++);
}
Infinite
255
256
127
Question 18
What is maximum number of 'case' values in a switch statement?
255
127
No specific limit
128
Question 19
What is the output of the program?
void main()
{
int x = (90, x = 90)+++x;
printf("\n %d ", x);
}
90
1
181
91
Question 20
Where do we use a 'continue' statement?
In 'if' statement
In 'switch' statement
In 'goto' labels
None of the above
Answers
Answer 1 - C
Answer 2 - A
Answer 3 - B
Answer 4 - D
Answer 5 - D
Answer 6 - D
Answer 7 - C
Answer 8 - C
Answer 9 - A
Answer 10 - C
Answer 11 - A
Answer 12 - A
Answer 13 - D
Answer 14 - D
Answer 15 - A
Answer 16 - A
Answer 17 - A
Answer 18 - C
Answer 19 - C
Answer 20 - D
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment