Reasoning,aptitude search engine

Custom Search

C,C++,java,SQL,PL/SQL Search Engine

Write a c programming code to create simple paint brush software.

#include<dos.h>
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{
int x,y,b,px,py,c,p,s,cl;
int d=0,m;
union REGS i,o;
initgraph(&d,&m,"c:\tc");
i.x.ax=1;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=20;
i.x.dx=450;
int86(0x33,&i,&o);
printf("Brush style insert number from 0 to 5  : ");
scanf("%d",&p);
printf("Brush size insert number from 1  to 7  : ");
scanf("%d",&s);
printf("Brush color insert number from 1 to 16 : ");
scanf("%d",&cl);
clrscr();
cleardevice();
printf("\t\t**********DRAW IMAGE************");
while(!kbhit())
{
i.x.ax=3;
b=o.x.bx;
x=o.x.cx;
y=o.x.dx;
px=x;
py=y;
int86(0x33,&i,&o);
if(cl==16)
{
c=random(16);
}
else
{
c=cl;
}
setcolor(c);
if(b==1)
{
i.x.ax=3;
int86(0x33,&i,&o);
x=o.x.cx;
y=o.x.dx;
b=o.x.bx;
switch(p)
{
case 1:circle(px,py,s);break;
case 2:ellipse(px,py,0,270,s,s+2);break;
case 3:fillellipse(px,py,s+2,s);break;
case 4:rectangle(px,py,x,y);break;
case 5:sector(px,py,30,120,s,s);break;
default:line(px,py,x,y);
}
}
}
getch();
restorecrtmode();
closegraph();
}

Objectives questions in advance c

(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)

Cursor program by c programming.

(1) Write a c program which changes the position of cursor?
Answer:
#include<dos.h>
#include<stdio.h>
void main()
{
union REGS i,o;
i.h.ah=2;   //positioning the cursor 
i.h.bh=0;
i.h.dh=30;   
i.h.dl=45;
int86(0x10,&i,&o);
printf("World");
getch();
}