Good questions on Advance C programming Language

(1) What will happen when you will compile and execute the following code?

#include”dos.h”
#include”stdio.h”
void main()
{
int x,y,b;
union REGS i,o;
i.h.ah=0;
i.h.al=0x13;
int86(0x10,&i,&o);
getch();
}
(a)It will switch to 32 bit color graphics mode.
(b)It will switch to 256 bit color graphics mode.
(c)It will switch to 32 bit text mode.
(d)It will switch to 256 bit text mode.

Answer: (b)

(2) What will happen when you will compile and execute the following code?

#include”dos.h”
void main()
{
union REGS i,o;
i.h.ah=0x39;
i.x.dx="ravan";
int86(0x21,&i,&o);
getch();
}
(a) It will create a file in current working directory.
(b) It will create a file in bin directory.
(c) It will create a directory in current working directory.
(d) It will create a directory in bin directory.

Answer: (c)

(3) What will output when you will compile and execute the following code?

void main()
{
clrscr();
    asm mov ax,15;
    asm mov bx,1;
    india:
    asm xor ax,5;
    asm dec bx;
    asm jz india;
printf("%d ",_AX);
getch();
}

(a)20
(b)15
(c)21
(d)Infinite loop

Answer: (b)

Explanation:
Statement jz India means jump to label india till content of last register i.e. bx is zero. When content of register bx became not zero then stop the jumping.

(4) What will happen when you will compile and execute the following code?

void main()
{
int num;
clrscr();
scanf("%d",&num);
asm mov ax,1;
asm mov bx,1;
asm mov cx,num;
come:
asm mul bx;
asm inc bx;
asm dec cx;
asm jnz come;
printf("%d ",_AX);
getch();
}
(a)It will convert given decimal number to binary number.
(b)It will convert given decimal number to hexadecimal number.
(c)It will produce fibonacii series up to given number.
(d)It will produce factorial of given number.
Answer: (d)

(5) What will happen when you will compile and execute the following code?

void main()
{
clrscr();
asm{
         mov ax,10;
         shl,2;
}
printf("%d",_AX);
getch();
}
(a)2
(b)40
(c)20
(d)10

Answer: (b)

Explanation:
ax and bx is general purpose register.
Statement mov ax,61 means value 61 is storing at register ax.
Statement shl 2 is equivalent to a<<2>

0 comments:

Post a Comment