Tuesday, July 7, 2009

C programming TECHNICAL MCQ Exercise -4

Q. 1 . Choose the wrong one
a . A structure can be nested within same structure
b . A value of one structure variable can be assigned to another structure variable
of same or different type.
c . It is illegal to use the structure itself as its member.
d . In self referential structure one member must be a pointer type.

Q. 2 . Find out the output
void main()
{
register int x;
scanf("%d",&x);
printf("%d",x);
}
If the value x is given 5 then output will be
a . 5
b . 0
c . Garbage
d . Error

Q. 3 . Find the output
#define float int
void main()
{
int x=10;
float y=3;
y=x%y;
printf("%f",y);
}
a . 0
b . 1
c . 1.000000
d . Error, floating point format not linked

Q. 4 . Which of the following is a miscellaneous directive?
a . #undef
b . #error
c . #elif
d . #include

Q. 5 . State the correct statement.
a . Linker combines different source files before compilation.
b . Linker combines different object files before execution.
c . Linker expands different source files before compilation.
d . none of these

Q. 6 . Find out the output.
void main()
{
int n=5;
if(n==5?printf("Hallo"):printf("Hai"),printf("Bye"));
}
a . HalloBye
b . Hallo
c . Expression syntax error
d . HaiBye

Q. 7 . Find the output
int x,y;
void main()
{
show(&x,&y);
printf("%d %d",x,y);
}
show(int *x,int *y)
{
*x++;
*y++;
}
a . 0 0
b . 1 1
c . Garbage output
d . None of these

Q. 8 . The different models used to organize data in the secondary memory are collectively called as
a . File structures
b . Data structures
c . Self referential structures
d . None of these

Q. 9 . Find the output
void main()
{
printf("%f",(float)9/5);
}
a . 1.8
b . 1.0
c . 2.0
d . None of these

Q. 10 . Find out the output
void main()
{
int static auto x;
x=5;
printf("%d",++x);
x--;
printf("%d",x);
}
a . Too many storage classes in declaration
b . 6 5
c . 6 6
d . None of these

Q. 11 . Find the output.
void main()
{
int x=5;
char a[x]={‘a’,’b’,’d’};
printf("%c",++1[a]);
}
a . b
b . c
c . d
d . None of these

Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in
a . ABCD order
b . DCBA order
c . Depends on system type
d . None of these

Q. 13 . A bit field can be of
a . int
b . float
c . double
d . All of these

Q. 14 . The synonym for an existing data type can be created using
a . typedef
b . structure
c . enum
d . All of the above

Q. 15 . Which of the following is best suited for memory optimization
a . Union
b . Self referential structure
c . Array
d . Linked list

Q. 16 . Find out the output
#include"fcntl.h"
#include"sys\stat.h"
void main()
{
int x;
x=open("raja.txt",O_CREATO_TEXT, S_IWRITE);
printf("%d",x);
}
a . 5
b . 6
c . 7
d . None of these

Q. 17 . All structure variables are created in
a . Code area
b . Stack area
c . Uninitialized data area
d . Initialized data area

Q. 18 . Cast operator returns
a . Lvalue
b . Rvalue
c . Integral value
d . None

Q. 19 . Find the output
void main()
{
int i;
for(i=1;i<=3;i++)
 { 
print: printf("C"); 
printf("%d",i);
 } 
a . Error,':' tag not allowed within the loop
 b . 1 2 3 
c . C 1 C 2 C 3
 d . Garbage value 

Q. 20 . Find the correct output
 void main() { 
int i=100; float f=5.413; 
print(i,f); 
print(i,f) { 
printf("%d %f",i,f); } 
a . 100 5.413 b . 100 5.000 c . 100 0.000 d . Error 

Q. 21 . Find out the output 
void main(void) { 
char numbers[5][6]={"Zero","One","Two","Three","Four"}; 
int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++);
 } 

a . eoOeToTreFu b . Zero c . Zr d . Compile time error 

Q. 22 . Find out the output 
void main() { int a[]={1,2,3,4,5};
 int j; for(j=0;j<5;j++) 
x="10,y;" y="choose(x);">=5)
return(y);
else
return(0);
}
a . 10
b . 0
c . Can’t determine
d . Error

Q. 24 . Find the correct output
#define div(x) x/x
void main()
{
printf("%d",div(16)*16);
}
a . 1
b . 16
c . 256
d . None of these

Q. 25 . What is the formula to find real address from 16-bit physical address?
a . segment address*16+offset address
b . segment address+offset address *16
c . segment address*10+offset address
d . segment address+offset address *10

Q. 26 . Which of the following function is appropriate to read one character at a time?
a . fscanf()
b . fgetc()
c . read()
d . fgets()

Q. 27 . Find the correct output
void main()
{
int a;
char b;
float c;
printf("%d",sizeof(a+sizeof(b+c));
}
a . 2
b . 1
c . 4
d . Error

Q. 28 . Find the output.
void main()
{
int x=5;
for (;x<=5;if(x==5)) printf("%d",++x); } a . 5 b . 6 c . Error d . No output

Q. 29 . Find the output
void main() {
int i=-3,j=2,k=0,m;
m=++i && j++ && ++k;
printf("\n%d, %d, %d, %d",i,j,k,m);
}
a . -2,-3, 1,1
b . -3, 2, 0,1
c . -2, 3, 0,1
d . -2, 3, 1,1

Q. 30 . Find out the output.
void main()
{
char *s="Rani";
printf("%s\r%s",s,s);
}
a . Rani
b . RaniRani
c . Rani\0
d . Ranii

No comments:

Blog List