Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -2

Q. 1 . Find out the output
void main()
{
int val=1234;
int *ptr=&val;
printf("%d %d",++val,(*(int *)ptr)--);
}
a . 1234 1233
b . 1235 1234
c . 1234 1234
d . None of these

Q. 2 . Find the correct output
void main()
{
int a=0;
for(a;++a;a<=100) 
printf("%d",a);
 } 
a . Print 1 to 99 infinite times 
b . Print 1 to 99 
c . Print some garbage values 
d . Infinite loop 

Q. 3 . Find the output 
void main() 
char c[6+4]="kill me"; 
printf("2%s",c); 
a . ki 
b . me 
c . kill me 
d . 2kill me 

Q. 4 . Find out the output 
main() 
int i=0; 
for(;i++;printf("%d",i)) ;
 printf("%d",i); }
 a . Infinite loop 
b . 0 1
 c . 1 
d . Stop after printing upto INT_MAX 

Q. 5 . Find out the output. 
int main(int k)
 {
 if(k<5) 
a="5,b="3,c="2;">b=2?z>3?1:2:3:4);
}
a . 1
b . 2
c . 3
d . 4

Q. 14 . Find the correct output
void main()
{
int i,j=6;
for(;i=j;j-=2)
printf("%d",j);
}
a . Error
b . Garbage values
c . 642
d . 6420

Q. 15 . State the correct statement.
a . In a while loop the control conditional check is performed n times.
b . In a do-while loop the control conditional check is performed n+1 times.
c . Break is a keyword used with if and switch case.
d . None of these.

Q. 16 . Find out the output
void main()
{
printf("3","%f",4);
}
a . 34.000000
b . 4
c . 3
d . Error

Q. 17 . What happens when subscript used for an array exceeds the array size?
a . Compiler gives an error message
b . Simply placed excess data outside the array
c . Simply placed excess data on top of other data or on the program itself.
d . The program must be compiled.

Q. 18 . The order of evaluation of operators having same precedence is decided by
a . Associativity rule
b . Precedence rule
c . Left-right rule
d . Right-left rule

Q. 19 . The set of routines stored in ROM that enable a computer to start the O.S and to communicate with the various devices in the system is known as
a . device driver
b . boot parameter
c . bios
d . none of these

Q. 20 . Find the output
struct main
{
int n;
int (*p)();
};
void main()
{
struct main m;
int fun();
m.p=fun();
*(m.p);
}
fun()
{
printf("Hallo");
}
a . Hallo
b . HalloHallo
c . Error
d . No output

Q. 21 . Find the output
union uni
{
int x;
int a:8;
char b:8;
}
void main()
{
union uni u={48};
printf("%d %c", u.a,u.b);
}
a . Invalid initialization
b . 48 0
c . 48 48
d . 0 0

Q. 22 . An AND gate
a . implements logical addition
b . is equivalent to a series switching circuit
c . implements logical subtractions
d . is equivalent to a parallel switching circuit

Q. 23 . Find the output
void main()
{
goto cite;
{
static int a=10;
cite: printf("%d",a);
}
}
a . 10
b . Warning, unreachable code
c . Error
d . Garbage value

Q. 24 . Find out the output
void main()
{
int i=3,j=2,k=1;
printf("%d / %d");
}
a . 1
b . 0
c . 3/2
d . 1/2

Q. 25 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.

Q. 26 . which of the following declaration is incomplete type?
(1) struct tag;
(2) struct tag {int a };
(3) typedef struct{int a:}abc
a . 1 only
b . 1 and 2 only
c . 1 and 3 only
d . 2 and 3 only

Q. 27 . Find the odd one out
a . #elif
b . #line
c . #else
d . #ifdef

Q. 28 . The ‘continue’ statement is used to
a . Continue the next iteration of a loop construct.
b . Exit the block where it exists and continues after.
c . Exit the outermost block even if it occurs inside the innermost.
d . Continue the compilation even an error occurs in a program.

Q. 29 . What is the value of EOF which is declared in "stdio.h"?
a . 0
b . -1
c . Any positive value
d . None of these

Q. 30 . Which data type behaves like both integer type and character type?
a . short int
b . signed int
c . char
d . enum

No comments:

Blog List