| [Q001] What will be the output of the following program
: |
int main()
{
int const *iptr=5;
printf("%d",++(*iptr));
return 0;
}
|
(a)5 (b)Compile-Time Error (c)6 (d)None of
these |
|
|
| [Q002] What will be the output of the following
program : |
int main()
{
static int val = 5;
printf("%d ",val--);
if (val)
main();
return 0;
}
|
(a)5 (b)Compile-Time
Error (c)Run-Time Error (d)5 4 3 2 1 (e)None
of these |
|
|
| [Q003] Identify the fault in the following program : |
int main()
{
char *s = (char *) malloc(10 * sizeof(char));
free(s);
free(s);
return 0;
}
|
(a)Compile-Time
Error (b)Run-Time Error (c)Linker-Error (d)None
of these |
|
|
| [Q004] Identify the fault in the following
program : |
void foo()
{
char *s = (char *) malloc(10 * sizeof(char));
}
int main()
{
foo();
return 0;
}
|
(a)No faults (b)Runtime-Error : Memory
Corruption (c)Performance Bottleneck : Memory Leak (d)Runtime-Error
: Pointer abuse |
|
|
| [Q005] Identify the fault in the following
program : |
int
main() { int val[5]={1,2,3,4,5};
val[5] = 100;
printf("%d",val[5]); return 0; }
|
(a)No faults (b)Run-Time Error : Boundary
overflow (c)Performance Bottleneck : Memory Leak (d)Run-Time
Error : Pointer abuse |
|
|
| [Q006] What will be the output of the following
program : |
struct { int bit:1; }
x;
int foo()
{
if ( x.bit > 0 ) return !0;
else return 0;
}
int main()
{
x.bit = 1;
if ( foo() ) printf( "bit status is ON" );
else printf( "bit status is OFF" );
return 0;
}
|
(a)bit status is ON (b)Compile-Time
Error (c)bit status is OFF (d)None of
these |
|
|
| [Q007] What will be the output of the following
program : |
int
main() { unsigned int a=-1;
int b;
b = ~0;
if (a == b)
printf("equal");
else
printf("not equal");
return 0; }
|
(a)equal (b)not equal (c)Compile-Time
Error (d)None of these |
|
|
| [Q008] What will be the output of the following
program : |
int
main() { 500; printf("%d",500); return(0); }
|
(a)500 (b)Run-Time Error (c)Compile-Time
Error (d)None of these |
|
|
| [Q009] What will be the output of the following
program : |
aaa()
{
printf("hi!");
}
bbb()
{
printf("hello");
}
ccc()
{
printf("bye");
}
int main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[1]();
return 0;
}
|
(a)hi! (b)hello (c)bye (d)Compile-Time
Error (e)None
of these |
|
|
| [Q010] What will be the output of the following
program : |
int
main() { float i=1.5;
switch(i)
{
case 1: printf("1"); break;
case 2: printf("2"); break;
default : printf("0");
} return(0); }
|
(a)1 (b)2 (c)Compile-Time
Error (d)0 (e)None of
these |
|
|
|
Click
Here - SOLUTIONS
- Weekly queries - Week1 - June 2005
|
|
Send
your feedback about Weekly queries - Week1 - June 2005
section to nandakishorkn@rediffmail.com
|
|
|