:::::Shikhor Himadrir :::::

Please Give your valuable comments on my blogs and make me more responsible blogger
Thursday 13 May 2010

Register & Register Transfer in Digital Systems

Flip Flops

In every digital system where all storage elements are employed during clock pulse is called sequential circuit . Modern computers also have sequential circuit design inside the CPU. This type of sequential circuit uses a special component called flip flop. Each flip flop can hold one storage data element in terms of bit. So we can say that 1 flip flop can hold 1 bit of data. Flip flops are use in sequential circuits because they can make change of their stored data when a clock pulse is applied .Flip flops are also well known as binary cell as it can store data in binary signal 1 or 0 format. There are various types of flip flops. But generally all types of flip flops have 2 outputs , one is normal and one is complement and all flip flops have clock pulse line . The difference among various types of flip flops is in the number of inputs they possess and in the manner in which the inputs affect the binary state. SR-type, JK-type, T-type, D-type are the most common flip flops. Internally all flip flops are made of combinational circuit design using digital components like logic gates. So because of combinational structures every flip-flops have their own different truth tables and equations. for example both SR-type flip flops and JK-type flip flops have same numbers of inputs, but they are completely different in truth tables and equations





figure : SR-type and JK-type Flip flop







figure : T-type and D-type Flip flop



Register

Complex digital systems which deals with lots of tasks like logic operation, arithmetic operation contains many hardware whose are interconnected among them. These hardware modules are internally made of some digital components like register, decoder, logic control etc. So registers plays an important role in digital systems. Registers store all of the binary bits on which any specific task can be done. These tasks are called micro operations. For example if computer wants to perform addition of two numbers than inside CPU the ALU unit will transfer add-micro operation signal to registers to perform addition between two numbers. After a task performed on register's containing bits , the bit values may or may not change. depending on the task condition. A register is a group of of flip flops with each flip flop capable of storing 1 bit of information . So an n-bit register contains n numbers of flip flops. Because of simplicity D-type flip flops are most commonly used flip flop.




figure : 4-bit register using d-type flip flop



Register Transfer Language

Digital systems which use registers have a control and a list of micro operations. This control selects some of the micro operations from the list and transfers them in a sequence to one or more registers to perform on its stored binary bit values. For example ALU is the control for CPU unit. So these types of digital systems hardware design can be define if we keep 3 important things in our mind:


1. The set of registers it contains and their functions.

2 The sequence of micro operations performed on the bit values inside the registers.

3. The control that initiates the sequence of micro operations.

The sequence of micro operations can be transfer to registers in lengthy descriptive words but as it is lengthy the processing will slow down its speed. Instead of this if we use any symbolic notations to indicate the same of micro operations, and then the processes will be simpler to handle with faster speed. The notation which expresses the sequence of micro operations in a simple manner is called Register Transfer Language. Some basic symbols are given below:



figure : basic symbols in Register Transfer Language - RT L


Register Transfer Concept


Using R T L-Language

In this type of digital systems first the control choose some micro operations in a sequence and then transfer them to one or more registers to perform some tasks on registers containing bit values. The entire works can be done just by expressing the works in RT L-Register Transfer Language notation.For example suppose a control is denoted by symbol 'P' and two register R1, R2. if we wants to perform a transfer of bit values from register R2 to R1,then we can write the entire expression in RT L is given in below figure :





It means that , when the control get value 1 and the clock pulse rise then it will load the register R1 so that the transfer can be from R2 to R1.So one can easily see that , the control is acting like a door of register R1. The given figure will explain all things which are happening inside the system:





In RT L-language system more then one micro operations are separated by commas.


In RT L-language system the group of bits content of register can be express by specifying the bits index range [means the flip flop index] or by the giving sign L or H [means Lower or Higher bits ] inside a parentheses ( ).





figure : transferring a group of bits




Friday 7 May 2010

The Calculator Implementation In java

Introduction
In this blog i am going implement the simple calculator in java.I will try to explain all the things that are very important and anyone who is familiar with java GUI programing can easily understand the source code.

Before you start, please be sure that you have the latest Netbeans version and java run time environment software.You can download tease two software from the link given bellow :-

http://netbeans.org/downloads/

http://java.sun.com/javase/downloads/index.jsp


The Calculator Screen
If we run the java source code, we will see a calculator like this :-



To exit the calculator correctly , we must click the File option given in the picture bellow :-



Here Is the Complete Source Code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package calculator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;


/**
*
* @author himadree
*/
public class Main extends JFrame implements ActionListener {

/**
* @param args the command line arguments
*/
final int MAX_INPUT_LENGTH = 20;
final int INPUT_MODE = 0;
final int RESULT_MODE = 1;
final int ERROR_MODE = 2;
int displayMode;

boolean clearOnNextDigit, percent;
double lastNumber;
String lastOperator;

private JMenu jmenuFile, jmenuHelp;
private JMenuItem jmenuitemExit, jmenuitemAbout;

private JLabel jlbOutput;
private JButton jbnButtons[];
private JPanel jplMaster, jplBackSpace, jplControl;

/*
* Font(String name, int style, int size)
Creates a new Font from the specified name, style and point size.
*/

Font f12 = new Font("Times New Roman", 0, 12);
Font f121 = new Font("Times New Roman", 1, 12);


// Constructor
public Main()
{
/* Set Up the JMenuBar.
* Have Provided All JMenu's with Mnemonics
* Have Provided some JMenuItem components with Keyboard Accelerators
*/

jmenuFile = new JMenu("File");
jmenuFile.setFont(f121);
jmenuFile.setMnemonic(KeyEvent.VK_F);

jmenuitemExit = new JMenuItem("Exit");
jmenuitemExit.setFont(f12);
jmenuitemExit.setAccelerator(KeyStroke.getKeyStroke( KeyEvent.VK_X,
ActionEvent.CTRL_MASK));
jmenuFile.add(jmenuitemExit);

jmenuHelp = new JMenu("Help");
jmenuHelp.setFont(f121);
jmenuHelp.setMnemonic(KeyEvent.VK_H);

jmenuitemAbout = new JMenuItem("About Calculator");
jmenuitemAbout.setFont(f12);
jmenuHelp.add(jmenuitemAbout);

JMenuBar mb = new JMenuBar();
mb.add(jmenuFile);
mb.add(jmenuHelp);
setJMenuBar(mb);

//Set frame layout manager

setBackground(Color.gray);

jplMaster = new JPanel();

jlbOutput = new JLabel("0");
jlbOutput.setHorizontalTextPosition(JLabel.RIGHT);
jlbOutput.setBackground(Color.WHITE);
jlbOutput.setOpaque(true);

// Add components to frame
getContentPane().add(jlbOutput, BorderLayout.NORTH);

jbnButtons = new JButton[23];


JPanel jplButtons = new JPanel(); // container for Jbuttons

// Create numeric Jbuttons
for (int i=0; i<=9; i++) { // set each Jbutton label to the value of index jbnButtons[i] = new JButton(String.valueOf(i)); } // Create operator Jbuttons jbnButtons[10] = new JButton("+/-"); jbnButtons[11] = new JButton("."); jbnButtons[12] = new JButton("="); jbnButtons[13] = new JButton("/"); jbnButtons[14] = new JButton("*"); jbnButtons[15] = new JButton("-"); jbnButtons[16] = new JButton("+"); jbnButtons[17] = new JButton("sqrt"); jbnButtons[18] = new JButton("1/x"); jbnButtons[19] = new JButton("%"); jplBackSpace = new JPanel(); jplBackSpace.setLayout(new GridLayout(1, 1, 2, 2)); Color c = new Color(70,50,30 ); jbnButtons[20] = new JButton("Backspace"); jbnButtons[20].setBackground(c); jplBackSpace.add(jbnButtons[20]); jplControl = new JPanel(); jplControl.setLayout(new GridLayout(1, 2, 2 ,2)); jbnButtons[21] = new JButton(" CE "); jbnButtons[21].setBackground(c); jbnButtons[22] = new JButton("C"); jbnButtons[22].setBackground(c); jplControl.add(jbnButtons[21]); jplControl.add(jbnButtons[22]); // Setting all Numbered JButton's to Blue. The rest to Red for (int i=0; i<20) i="7;" i="4;" i="1;" and =" jplButtons.add(jbnButtons[0]);" i="0;" add="" windowlistener="" closing="" frame="" and="" ending="" program="" new="" windowevent="" contructor="" perform="" action="" public="" void="" actionevent="" double="" result="0;" jdialog="" dlgabout="new" about="" java="" swing="" calculator="" else="" search="" the="" button="" pressed="" until="" end="" of="" array="" or="" key="" found="" for="" int="" i="0;">< inputstring =" getDisplayString();" inputstring =" inputString.substring(1);"> 0)
&& inputString.length() < displaymode =" INPUT_MODE;" clearonnextdigit =" false;" displaymode =" INPUT_MODE;" inputstring =" getDisplayString();" displaymode ="="" input =" getDisplayString();"> 0 && !input.equals("0"))
{
if (input.indexOf("-") == 0)
setDisplayString(input.substring(1));

else
setDisplayString("-" + input);
}

}

else if (displayMode == RESULT_MODE)
{
double numberInDisplay = getNumberInDisplay();

if (numberInDisplay != 0)
displayResult(-numberInDisplay);
}
}

void clearAll() {
setDisplayString("0");
lastOperator = "0";
lastNumber = 0;
displayMode = INPUT_MODE;
clearOnNextDigit = true;
}

void clearExisting(){
setDisplayString("0");
clearOnNextDigit = true;
displayMode = INPUT_MODE;
}

double getNumberInDisplay() {
String input = jlbOutput.getText();
return Double.parseDouble(input);
}

void processOperator(String op) {
if (displayMode != ERROR_MODE)
{
double numberInDisplay = getNumberInDisplay();

if (!lastOperator.equals("0"))
{
try
{
double result = processLastOperator();
displayResult(result);
lastNumber = result;
}

catch (DivideByZeroException e)
{
}
}

else
{
lastNumber = numberInDisplay;
}

clearOnNextDigit = true;
lastOperator = op;
}
}

void processEquals(){
double result = 0;

if (displayMode != ERROR_MODE){
try
{
result = processLastOperator();
displayResult(result);
}

catch (DivideByZeroException e) {
displayError("Cannot divide by zero!");
}

lastOperator = "0";
}
}

double processLastOperator() throws DivideByZeroException {
double result = 0;
double numberInDisplay = getNumberInDisplay();

if (lastOperator.equals("/"))
{
if (numberInDisplay == 0)
throw (new DivideByZeroException());

result = lastNumber / numberInDisplay;
}

if (lastOperator.equals("*"))
result = lastNumber * numberInDisplay;

if (lastOperator.equals("-"))
result = lastNumber - numberInDisplay;

if (lastOperator.equals("+"))
result = lastNumber + numberInDisplay;

return result;
}

void displayResult(double result){
setDisplayString(Double.toString(result));
lastNumber = result;
displayMode = RESULT_MODE;
clearOnNextDigit = true;
}

void displayError(String errorMessage){
setDisplayString(errorMessage);
lastNumber = 0;
displayMode = ERROR_MODE;
clearOnNextDigit = true;
}


public static void main(String[] args) {
// TODO code application logic here
Main calci = new Main();
Container contentPane = calci.getContentPane();
calci.setTitle("Java Calculator ");
calci.setSize(250, 220);
calci.pack();
calci.setLocation(200, 300);
calci.setVisible(true);
calci.setResizable(false);

}

}


class DivideByZeroException extends Exception{
public DivideByZeroException()
{
super();
}

public DivideByZeroException(String s)
{
super(s);
}
}

class CustomABOUTDialog extends JDialog implements ActionListener {
JButton jbnOk;

CustomABOUTDialog(JFrame parent, String title, boolean modal){
super(parent, title, modal);
setBackground(Color.black);

JPanel p1 = new JPanel(new FlowLayout(FlowLayout.CENTER));

StringBuffer text = new StringBuffer();
text.append("Calculator \n\n");
text.append("Developer: Himadree\n");
text.append("Version: 1.0");

JTextArea jtAreaAbout = new JTextArea(5, 21);
jtAreaAbout.setText(text.toString());
jtAreaAbout.setFont(new Font("Times New Roman", 1, 13));
jtAreaAbout.setEditable(false);

p1.add(jtAreaAbout);
p1.setBackground(Color.red);
getContentPane().add(p1, BorderLayout.CENTER);

JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER));
jbnOk = new JButton(" OK ");
jbnOk.addActionListener(this);

p2.add(jbnOk);
getContentPane().add(p2, BorderLayout.SOUTH);

setLocation(408, 270);
setResizable(false);

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
Window aboutDialog = e.getWindow();
aboutDialog.dispose();
}
}
);

pack();
}

public void actionPerformed(ActionEvent e)
{
if(e.getSource() == jbnOk) {
this.dispose();
}
}

}



Note : For more information, you can also visit my other blogs. And don't forget to give your valuable comments.

Saturday 1 May 2010

The Snake Game In C

Introduction

This is a small turbo c program of snake game using
some graphics.h functions. Anyone who is familiar with C graphics
programming can do it very easily
.

Code Explanation
In the beginning of code explanation the first important part is
initializing the graphics mode in turbo C to do drawing a calculator and
that is must be done before using every graphics related functions. This
graphics initialization is done by a pre-define function called initgraph()
with a tiny code part given below :

int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

If your TC folder is in D drive than just type "D:\\TC\\BGI" instead of
"C:\\TC\\BGI"

inside the initgraph( ) function.So if you want to use graphics functions in
your turbo c program, than you have to always write these two statement in
the main( ) function.


If you initialize the graphics mode than, all graphics.h function can be use
in the program.But if you need to come back to the normal textmode (the
black screen ) than you have to shut down the graphics mode by using the
graphics.h function closegraph( ).


In that program we have use three user-define functions given below :
void check();
void end();
void win();

The first screen shot will be like this :-




The gaming screen will be look like this :-




Here is the source code
#include "graphics.h"
#include 'stdlib.h"
#include "dos.h"
#include "conio.h"
#include "stdio.h"
#include "time.h"

int m[500],n[500],con=20,TEMP;
clock_t start,stop;

void main(void)
{



int gd=DETECT,gm,ch,maxx,maxy,x=13,y=14,p,q,spd=100;

int a=0,i=0,j,t,temp;

initgraph(&gd,&gm,"C:\\TC\\BGI");

setcolor(6);

settextstyle(1,0,6);

outtextxy(20,2," SNAKE 2 BY Himadree ");

settextstyle(6,0,2);

outtextxy(20,80," Use Arrow Keys To Direct The Snake ");

outtextxy(20,140," Avoid The Head Of Snake Not To Hit Any Part Of
Snake");

outtextxy(20,160," Pick The Beats Untill You Win The Game ");

outtextxy(20,200," Press 'Esc' Anytime To Exit ");

outtextxy(20,220," Press Any Key To Continue ");

outtextxy(20,240," DONT FORGET TO GIVE U R VALUABLE OPINION ");

ch=getch();

if(ch==27) exit(0);

cleardevice();

maxx=getmaxx();

maxy=getmaxy();

randomize();
p=random(maxx);
temp=p%13;
p=p-temp;
q=random(maxy);
temp=q%14;
q=q-temp;
start=clock();

while(1)
{

setcolor(WHITE);
setfillstyle(SOLID_FILL,con+5);
circle(p,q,5);
floodfill(p,q,WHITE);
if( kbhit() )
{

ch=getch(); if(ch==0) ch=getch();

if(ch==72&& a!=2) a=1;

if(ch==80&& a!=1) a=2;

if(ch==75&& a!=4) a=3;

if(ch==77&& a!=3) a=4;


}
else
{

if(ch==27){

break;


}

}

if(i<20){

m[i]=x;


n[i]=y;

i++;

}

if(i>=20)
{

for(j=con;j>=0;j--){

m[1+j]=m[j];

n[1+j]=n[j];


}

m[0]=x;
n[0]=y;
setcolor(WHITE);
setfillstyle(SOLID_FILL,con);
circle(m[0],n[0],8);
floodfill(m[0],n[0],WHITE);
setcolor(WHITE);
for(j=1;j<con;j++){

setfillstyle(SOLID_FILL,con+j%3);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);
}

delay(spd);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[0],n[0],8);
floodfill(m[0],n[0],BLACK);
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
circle(m[j],n[j],5);
floodfill(m[j],n[j],BLACK);
}

stop=clock();

t=(stop-start)/CLK_TCK;

check();

if(x==p && y==q)
{

con=con+5;

if(spd>=5)
spd=spd-5;
else spd=5;

if(con>490)

win();
p=random(maxx); temp=p%13; p=p-temp;
q=random(maxy); temp=q%14; q=q-temp;
}
if(a==1){
y = y-14;

}

if(y<0)
{

temp=maxy%14;y=maxy-temp;

}

if(a==2)
{

y = y+14;


}

if(y>maxy)

{

y=0;


}

if(a==3){

x = x-13;

}
if(x<0) {

temp=maxx%13;x=maxx-temp;

}

if(a==4){
x = x+13; if(x>maxx) x=0;

}

if(a==0)
{

y = y+14 ;

x=x+13;

}


}


}

void check(){

int a;
for(a=1;a<con;a++)

if(m[0]==m[a] && n[0]==n[a])
{
end();

}
else
{

continue;


}

}

void end()
{

int j,i;

setcolor(WHITE);

for(i=0;i<5;i++){

delay(500);
cleardevice();

delay(500);

for(j=0;j<=con;j++){

setfillstyle(SOLID_FILL,RED);
circle(m[j],n[j],5);
floodfill(m[j],n[j],WHITE);

}
}
settextstyle(3,0,4);
outtextxy(150,150," GAME OVER ");

getch();
getch();

exit(0);

}


void win()
{

int j,i;

setcolor(WHITE);

for(i=0;i<5;i++){

for(j=0;j<=con;j++){

setfillstyle(SOLID_FILL,con);


circle(m[j],n[j],5);

floodfill(m[j],n[j],WHITE);

}

delay(500);


cleardevice();

delay(500);

}

settextstyle(3,0,4);

outtextxy(210,320," YOU WIN ");


getch();

exit(0);

}


Note : For more information, you can also visit my other blogs. And don't forget to give your valuable comments.

Rabindranath Tagore Animation In Turbo C




Introduction
This is small animation of a poet Rabindranath Tagore in C.This animation is just build with using some graphics.h program and other time delay function.One who know C graphics program , will simply understand the animation source code.

In the beginning of code explanation the first important part is initializing the graphics mode in turbo C to do drawing this animation and that is must be done before using every graphics related functions.This graphics initialization is done by a pre-define function called initgraph() with a tiny code part given below :


int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

If your TC folder is in D drive than just type "D:\\TC\\BGI" instead of "C:\\TC\\BGI"
inside the initgraph( ) function.So if you want to use graphics functions in your turbo c program, than you have to always write these two statement in the main( ) function.

I just download some art pictures of Rabindranath Tagore and than made his animating photo with turbo c language.After running the program, the animation might look like the photo given bellow :-



Here is source code

#include "graphics.h"
#include "stdio.h"
#include "conio.h"
#include "dos.h"

int main(void)
{
/* request auto detection */
int gd = DETECT, gm;


/* initialize graphics and localvariables */
initgraph(&gd, &gm, "C:\\TC\\BGI");
arc(234, 125, 120, 190, 50);
line(185,135, 185,155);
arc(190, 162,120,280, 8);
arc(193, 175 , 300, 90, 6);
arc(198, 200, 100, 150, 20);

arc( 205,210, 140, 180, 30 );
line(176, 210, 176, 228);
arc(185, 229,180,310, 8);
line( 185, 238 ,200, 230);
arc(205, 230, 340, 180, 3);
line(205,232, 200, 258);
arc(212, 260, 160, 315, 12);
line(220, 270, 180, 310);
arc(210, 310, 180, 230, 30);
arc(205, 330, 30, 180,15);
arc(160, 330,290,5, 60);
arc(105, 360, 290, 340 ,80);
arc(145, 440, 165, 350,15);
arc(165, 420, 260, 360, 25);
line(190, 420, 230, 400);
arc(210, 218, 270, 360, 10);
arc(200, 280, 30, 80,65);
line(250, 280, 260, 250);
arc(268, 300,100, 270, 25);
arc(280, 335,140, 270, 15);
arc(260, 380,220, 300, 35);


arc(192, 142,180, 340, 6);
arc(218, 160, 40, 150,25);
arc(218, 164, 50, 150,25);
arc(200, 140,180, 250, 15);
line(208, 156, 230,148);
line(212, 172, 230, 148);
circle(212, 162, 6);
setfillstyle(SOLID_FILL, WHITE);
floodfill(213, 163, WHITE);
arc(280,152, 180, 230,70);

arc(275,158, 340,130, 100);
arc(305, 220, 330,30,70);
arc(305, 220, 330,30,80);
arc(305, 220, 330,30,82);
arc(305, 220, 330,30,75);
arc(305, 156,0, 150, 70);
arc(200, 160,0, 100, 60);

/* For hair */

arc(260, 140,0, 155, 90);
arc(260, 140,0, 154, 88);
arc(260, 140,0, 153, 86);
arc(260, 140,0, 152, 84);
arc(260, 140,0, 151, 82);

arc(260, 140,0, 149, 80);
arc(260, 140,0, 148, 78);
arc(260, 140,0, 147, 76);
arc(260, 140,0, 146, 74);
arc(260, 140,0, 145, 72);
arc(260, 140,0, 144, 70);
arc(260, 140,0, 143, 68);
arc(260, 140,0, 142, 66);
arc(260, 140,0, 141, 64);
arc(260, 140,0, 140, 62);
arc(260, 140,0, 139, 60);
arc(260, 140,0, 138, 58);
arc(260, 140,0, 137, 56);
arc(260, 140,0, 136, 54);
arc(260, 140,0, 135, 52);
arc(260, 140,0, 134, 50);
arc(260, 140,0, 133, 48);
arc(260, 140,0, 132, 46);
arc(260, 140,0, 131, 44);
arc(260, 140,0, 130, 42);
arc(260, 140,0, 129, 40);
arc(260, 140,0, 128, 38);
arc(260, 140,0, 127, 36);
arc(260, 140,0, 126, 34);
arc(260, 140,0, 125, 32);
arc(260, 140,0, 124, 30);
arc(260, 140,0, 123, 28);
arc(260, 140,0, 122, 26);
arc(260, 140,0, 121, 24);
arc(260, 140,0, 120, 22);
arc(260, 140,0, 119, 20);
arc(260, 140,0, 118, 18);
arc(260, 140,0, 117, 16);
arc(260, 140,0, 116, 14);
arc(260, 140,0, 115, 12);
arc(260, 140,0, 114, 10);
arc(260, 140,0, 113, 8);
arc(260, 140,0, 112, 6);
arc(260, 140,0, 111, 4);
arc(260, 140,0, 110, 2);

/* another hair style */
arc(282, 150, 330, 70, 88);
arc(282, 150, 330, 70, 86);
arc(282, 150, 330, 70, 84);
arc(282, 150, 330, 70, 82);
arc(282, 150, 330, 70, 80);
arc(282, 150, 330, 70, 78);
arc(282, 150, 330, 70, 76);
arc(282, 150, 330, 70, 74);
arc(282, 150, 330, 70, 72);
arc(282, 150, 330, 70, 70);
arc(282, 150, 330, 70, 68);


arc(310, 150,330, 90, 65);

/*----ANIMATION-----*/

while (!kbhit()){
setbkcolor(BLACK);
setcolor(WHITE);

delay(1000);
line(410,100, 440, 100);
line(440,100,390, 140);
line(390, 140, 430, 150);
line(440,100, 430, 150);
circle(410, 160, 2);
delay(1000);

putchar('\r');

line(460, 100, 490, 100);
line(490,100,440, 140);
line(440, 140, 480, 150);
line(490,100, 480, 150);
line(500,100, 490, 150);
arc(480,100,350,180, 20);
delay(1000);

putchar('\r');

line(510, 100, 550, 100);
line(530,100, 520, 150);
circle(505, 125, 3);
arc(525, 145, 90, 125, 30);
line(545, 130, 520, 150);
line(545, 130,560,150);
arc(565, 210, 92, 180,60);




delay(1000);
setbkcolor(BLACK);
setcolor(BLACK);


line(410,100, 440, 100);
line(440,100,390, 140);
line(390, 140, 430, 150);
line(440,100, 430, 150);
circle(410, 160, 2);


line(460, 100, 490, 100);
line(490,100,440, 140);
line(440, 140, 480, 150);
line(490,100, 480, 150);
line(500,100, 490, 150);
arc(480,100,350,180, 20);

line(510, 100, 550, 100);
line(530,100, 520, 150);
circle(505, 125, 3);
arc(525, 145, 90, 125, 30);
line(545, 130, 520, 150);
line(545, 130,560,150);
arc(565, 210, 92, 180,60);
}


getch();
closegraph();
return 0;
}

Note : For more information, you can also visit my other blogs. And don't forget to give your valuable comments.




Friday 30 April 2010

Scientific Calculator In C

Introduction
In this i have explained about the implementation of a scientific calculator using programing language Turbo C.This program comes with various turbo c graphics function.So i will try to explain.In this i have explained about the implementation of a scientific calculator using programing language Turbo C.This program comes with various turbo c graphics function.So i will try to explain all the tricky parts of code inside it.Those who are not familiar with the common functions and other simple contents of turbo C are requested to learn them from any other source, otherwise it may be problematic for you.

Special Thanks To :
Mr.Muhammad Saqib

The list of predefined functions in the code

#include stdio.h
functions :
printf( )

#include conio.h
functions :
clrscr( ) , getch( ) , kbhit( )

#include process.h
functions :
exit( )

#include dos.h
functions :
delay( ), int86( )

#include stdlib.h
functions :
atoi( ) , malloc( ) , free( )

#include graphics.h
functions:
setcolor( ), settextjustify( ), settextstyle( ), setusercharsize( ),setfillstyle( ), moveto( ), outtext(),outtextxy( ), line( ), getmaxx( ), getmaxy( ), gotoxy(), bar( ), rectangle( ),cleardevice( ), closegraph( ) initgraph( )
#include math.h
functions :
sqrt() , sin( ), cos( ), tan( ), asin( ), acos( ), atan( ), log10( ), pow( )

#include string.h
functions :
strlen() ;

The list of user-define function used in code
void typeit (int x,int y,int spacing,char string[]) ;
void front()
void frontpage(void)
char input();
double add(double,double,char);
double angle_conv(double);
void basecng(double,double);
void button_3d(int x1,int y1,int x2,int y2,int check,char* text,int color)
void screen(int x1, int y1, int x2, int y2);
void init_mouse();
void mouse();
void hide_mouse();
void show_mouse();
void remove_mouse();
void structure();

Source Code explanation
on that code i have have used some global variables, strings, constant which given below :

float *mem;
int X=0, Y=0;
int row=17,col=5;
char dummy;
char flag='d',flagp='0';
char bflag='u',bflagp='u';
int mflag=0;
char ch,ch1,ch2;
int sflag=0;
int midx,midy;
# define UNCLICKED 0
# define CLICKED 1
# define PI 3.14159

In the beginning of code explanation the first important part is initializing the graphics mode in turbo C to do drawing a calculator and that is must be done before using every graphics related functions.This graphics initialization is done by a pre-define function called initgraph() with a tiny code part given below :


int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

If your TC folder is in D drive than just type "D:\\TC\\BGI" instead of "C:\\TC\\BGI"
inside the initgraph( ) function.So if you want to use graphics functions in your turbo c program, than you have to always write these two statement in the main( ) function.

If you initialize the graphics mode than, all graphics.h function can be use in the program.But if you need to come back to the normal textmode (the black screen ) than you have to shut down the graphics mode by using the graphics.h function closegraph( ).

The First Opening Screen Animation :
When you run this program you will see a small animation just like given below





This part of the program is done by 2 user define function :
1. void typeit (int x,int y,int spacing,char string[]) :: this function types the programmer's name with green color and with other special effects by using delay( ) and other graphics.h functions

2. void front( ) :: This function draws the opening animation given in above picture.
The Second Screen
After getting this Opening Screen Animation , if you press any key than you will see the second screen just like given below



This second screen drawing is done by the function
void frontpage(void)
The Mouse Related Functions :
I have add mouse operation in this program , so to do this we need to initialize the mouse driver for activating the muse cursor and this is done by the function
void init_mouse() :: initialize the mouse driver.
void mouse() :: for each calculator button's action taken by the mouse.

Because in the graphics screen always we move the mouse cursor.So that the position of the mouse symbol changes by each an every movement.That means if we erase/hide the mouse symbol at the past position and draw/show the mouse symbol at the new position will make the mouse movement in normal. This hiding and showing of mouse is done by 2 mouse function :
1. void hide_mouse()
2. void show_mouse()





When we change the current mouse cursor position to the new one , the old position information (i.e: X-cordinate, Y-cordinate etc) has been removed by the new one and to do that operation we use the function void remove_mouse().


Remember one thing , that device like mouse are external things in graphics or dos mode.That means we are forcing the program to add external operations too .So we are actually interrupting the main to do the mouse operations and to do so we have called the function
int86(0x33,&ioRegs,&ioRegs);

NOTE: for further more information about mouse operations and the algorithms , please visit to my blog

The Display Screen Function
The display screen of the calculator is look like that :



This is is done by the function :-
void screen(int x1, int y1, int x2, int y2);

The 3D Buttons And Body Of Calculator:


All 3D buttons and the calculator body are create by the function :-
void button_3d(int x1,int y1,int x2,int y2,int check,char* text,int color)

The Complete Graphics Structure :


The complete graphics structure is done by the function :-
void structure();

The Graphics input :
Taking user's input in graphics mode is done by the function :-
char input();

The Arithmetical Calculations is done by the function :-
double add(double x,double y,char ch);

The Trigonometrical Calculations is done by the function :-
double angle_conv(double no);

The Number Base Changes are done by the function :-
void basecng(double y,double pnt1);

Here is the complete source code with comments :

#include stdio.h
#include conio.h
#include process.h
#include dos.h
#include stdlib.h
#include graphics.h
#include math.h
#include string.h




float *mem;
int X=0, Y=0;
int row=17,col=5;
char dummy;
char flag='d',flagp='0';
char bflag='u',bflagp='u';
int mflag=0;
char ch,ch1,ch2;
int sflag=0;
int midx,midy;
# define UNCLICKED 0
# define CLICKED 1
# define PI 3.14159

char str1[]={"Himadree Shekhar"};
void typeit (int x,int y,int spacing,char string[])
{
char temp[2];
for (int i=0;i<strlen(string);i++)
{
delay(100);
temp[0]=string[i];
temp[1]='\0';
outtextxy(x+(i+1)*spacing,y,temp);
}//endfor
}
void front()
{
int x,y,h;
for(x=0;x<=100;x++)
{
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(1);
settextstyle(3,0,1);
setusercharsize(x,6,x,3);
/*
moveto(int x, int y) function moves
the current position (CP) to position (x, y).
*/
/*
outtext(char far *textstring) function
outputs textstring at the current position (CP)
*/
setcolor(4);
moveto(335,140);
outtext("--");
if(x<50){
delay(60);
}
else{
delay(20);
}
}
for(y=0;y<=100;y++)
{
if(y>30 && y < 90){
setcolor(2);
settextstyle(1,0,4);
setusercharsize(y,6,y,3);
moveto(340,90);
outtext("-");
}

if(y>20)
{
settextstyle(7,0,3);
/*
setusercharsize(int multx, int divx, int multy, int divy);
function gives you finer control over the size of text
from stroked fonts used with graphics functions.
*/
setusercharsize(y-20,35,y-20,30);
setcolor(15);
outtext("CALCULATER");
delay(15);
if(y<100) // NESTED if block
{
settextstyle(7,0,3);
setusercharsize(y-20,35,y-20,30);
setcolor(0);
outtext("CALCULATER");
}
}
}
/*
settextstyle(int font, int direction, int charsize)
Sets the current text characteristics Like:-
font, direction , character size
*/
settextstyle(1,0,2);
//delay(50); is delaying the program execution for 50 ml.seconds
delay(50);
/*
outtextxy() function is from #include<graphics.h>
outtextxy(midx-200,midy,"By :-"); function displays
the argument string "By :-" from
starting cordinate (X,Y)= (midx-200,midy )
*/
/*
outtextxy(int x, int y, char far *textstring);
displays textstring at the position (x, y)
*/
outtextxy(midx-5,midy+100,"By");
/*
setcolor(int color); sets the current drawing color to color,
which can range from 0 to 15.
*/
setcolor(2);
settextstyle(0,0,1);
typeit(midx-150,midy+140,15,str1);
getch();
} // END OF FUNCTION : front()
char input();
double add(double,double,char);
double angle_conv(double);
void basecng(double,double);
/************************************************************/
/* */
/* THIS FUNCTION DRAWS THE BUTTONS OF THE CALCULATER */
/* */
/************************************************************/
void button_3d(int x1,int y1,int x2,int y2,int check,char* text,int color)
{
int up,low;
setfillstyle(1,7);
/*
bar(int left, int top, int right, int bottom) function
draws a filled-in, rectangular, two-dimensional bar
(left, top) is the top cordinate position of the one diametar
of the rectangular bar
(right, bottom) is the bottom cordinate position
of the one diametar of the rectangular bar
*/
bar(x1,y1,x2,y2);
if(check==0){ //Unclicked
up=15,low=0;
}
else{
up=0,low=15; //Clicked
}
setcolor(low);
/*
line(int x1, int y1, int x2, int y2)draws
a line from (x1, y1) to (x2, y2) using
the current color, linestyle, and thickness
*/
line(x2,y1,x2,y2);
line(x2-1,y1,x2-1,y2);
line(x1,y2,x2,y2);
line(x1+1,y2-1,x2,y2-1);
setcolor(up);
line(x1,y1,x2,y1);
line(x1+1,y1+1,x2-1,y1+1);
line(x1,y1,x1,y2);
line(x1+1,y1+1,x1+1,y2-1);
setcolor(color);
/*
settextjustify(int horiz, int vert)Text output after
a call to function settextjustify() is justified around the current
position (CP) horizontally and vertically, as specified.
*/
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(x1+(x2 - x1)/2,(y1+(y2 - y1)/2)-2, text);
}
/*********************************************************************/
/* */
/* This function makes the opening screen */
/* */
/*********************************************************************/
void frontpage(void)
{
int mx, my;
mx = (getmaxx() / 2);
my = (getmaxy() / 2);
//SET baqckground color
/*
setfillstyle(int pattern, int color)function
sets the current fill pattern and fill color
*/
setfillstyle(2, 8);
bar(0,0,getmaxx(),getmaxy());
//DRAW a bar, and make it look like a 3d bar
setfillstyle(1,1);
bar(50,20,600,400);
//DRAW lines for the top and left side
setcolor(15);
line(50,20,600,20);
line(51,21,599,21);
line(50,20,50,400);
line(51,21,51,399);
//DRAW lines for the bottom and right side
setcolor(8);
line(600,20,600,400);
line(599,21,599,400);
line(50,400,600,400);
line(51,399,600,399);
//DRAW two 3D bars for the left and right side
setfillstyle(4,2);
bar(70,40,100,380);
bar(545,40,575,380);
setcolor(4);
rectangle(70,40,100,380);
rectangle(545,40,575,380);
setcolor(15);
line(100,40,100,380);
line(70,380,100,380);
line(575,40,575,380);
line(545,380,575,380);
//DRAW two 3D divider lines on both sides
setcolor(2);
line(110, 40, 110, 380);
line(535, 40, 535, 380);
setcolor(4);
line(111, 40, 111, 380);
line(536, 40, 536, 380);
//PRINT 3D text CALENDAR 2002
settextstyle(1, 0, 4);
settextjustify(1,1);
setcolor(15);
outtextxy(mx+2, my - 46, "SCIENTIFIC CALCULATOR");
setcolor(7);
outtextxy(mx + 1, my - 45, "SCIENTIFIC CALCULATOR");
setcolor(8);
outtextxy(mx + 2, my - 44, "SCIENTIFIC CALCULATOR");
//PRINT 3D text 2010
setcolor(15);
outtextxy(mx, my + 10, "2010");
setcolor(7);
outtextxy(mx + 1, my + 11, "2010");
setcolor(8);
outtextxy(mx + 2, my + 12, "2010");
//PRINT copyright notice
settextstyle(2, 0, 5);
setcolor(15);
outtextxy(mx + 1, my + 85, "Copyright 2010 by NSU Creations");
getch(); //PAUSE for a while
}
/*********************************************************************/
/* */
/* This function makes the claculating screen */
/* */
/*********************************************************************/
void screen(int x1, int y1, int x2, int y2)
{
setlinestyle(0,0,1);
setfillstyle(SOLID_FILL, 8);
bar(x1, y1, x2, y2);
setfillstyle(SOLID_FILL, BLACK);
bar(x1+1, y1+1, x2-1, y2-1);


settextjustify(CENTER_TEXT, CENTER_TEXT);
setcolor(15);
line(x1+1, y1+1, x1+1, y2-1);
line(x1+1, y1+1, x2-1, y1+1);
line(x1+2, y1+2, x1+2, y2-2);
line(x1+2, y1+2, x2-2, y1+2);
setcolor(8);
line(x1+1, y2-1, x2-1, y2-1);
line(x2-1, y1+1, x2-1, y2-1);
line(x1+2, y2-2, x2-2, y2-2);
line(x2-2, y1+2, x2-2, y2-2);
} // END OF FUNCTION : void screen(int x1, int y1, int x2, int y2)

/************************************************************************/
/* */
/* Mouse Related Functions */
/* */
/************************************************************************/
void init_mouse()
{
union REGS iregs, oregs;
iregs.x.ax = 0;
int86 (0x33, &iregs, &oregs);
if (oregs.x.ax == 0)
{
cleardevice();
printf("mouse not installed\n");
getch();
exit(1);
}
iregs.x.ax = 1;
int86 (0x33, &iregs ,&oregs);
}
/*************************************************************/
void mouse()
{
int button,x1,y1;
union REGS iregs, oregs;
iregs.x.ax = 3;
int86 (0x33, &iregs ,&oregs);
button = oregs.x.bx & 3;
x1 = oregs.x.cx;
y1 = oregs.x.dx;
if(oregs.x.bx & 1)
{
X = x1 ; Y = y1;
}
if(button == 3)
{
/*
exit(int status); function
terminates the program
*/
exit(0);
}
}


/*************************************************************/
void hide_mouse()
{
union REGS ioRegs;
ioRegs.x.ax=2;
int86(0x33,&ioRegs,&ioRegs);
}


/*************************************************************/
void show_mouse()
{
union REGS ioRegs;
ioRegs.x.ax=1;
int86(0x33,&ioRegs,&ioRegs);
}
/*************************************************************/
void remove_mouse()
{
union REGS ioRegs;
ioRegs.x.ax=0;
int86(0x33,&ioRegs,&ioRegs);
}

/*************************************************************************/
/* */
/* THIS FUNCTION DRAWS THE CALCULATER ON THE SCREEN */
/* */
/*************************************************************************/
void structure()
{
init_mouse();
/*
setbkcolor(int color) function sets
the background to the color specified by color.
*/
setbkcolor(0);
/*
cleardevice(void) function erases
the entire graphics screen and moves
the CP (current position) to home (0,0).
*/
cleardevice();
hide_mouse();
//**********************************************************
// Buttons Making
front();
frontpage();
settextstyle(2,0,4);
button_3d(50,20,600,400,UNCLICKED,"",1); // main box
screen(100,50,545,120); // screen

setfillstyle(1,8);
bar(52,22,598,42);
button_3d(575,23,595,40,UNCLICKED,"x",0);
setcolor(0);
outtextxy(125,30,"Scientific Calculator 2010");
button_3d(108,140,208,160,UNCLICKED,"DEC",15); // box of decimal
button_3d(218,140,318,160,UNCLICKED,"OCT",0); // box of octal
button_3d(328,140,428,160,UNCLICKED,"HEX",0); // box of hexal
button_3d(438,140,538,160,UNCLICKED,"BIN",0); // box of binary
button_3d(350,205,380,225,UNCLICKED,"7",0); // Box Of 7
button_3d(390,205,420,225,UNCLICKED,"8",0); // Box Of 8
button_3d(430,205,460,225,UNCLICKED,"9",0); // Box Of 9
button_3d(350,230,380,250,UNCLICKED,"4",0); // Box Of 4
button_3d(390,230,420,250,UNCLICKED,"5",0); // Box Of 5
button_3d(430,230,460,250,UNCLICKED,"6",0); // Box Of 6
button_3d(480,230,510,250,UNCLICKED,"*",0); // Box Of *
button_3d(515,230,545,250,UNCLICKED,"/",0); // Box Of \
button_3d(480,205,510,225,UNCLICKED,"AC",4); //Box Of AllClear (AC)
button_3d(515,205,545,225,UNCLICKED,"CE",4); //Box Of Clear (C)
button_3d(350,255,380,275,UNCLICKED,"1",0); // Box Of 1
button_3d(390,255,420,275,UNCLICKED,"2",0); // Box Of 2
button_3d(430,255,460,275,UNCLICKED,"3",0); // Box Of 3
button_3d(350,280,380,300,UNCLICKED,"0",0); // Box Of Zero (0)
button_3d(390,280,420,300,UNCLICKED,".",0); // Box Of Period (.)
button_3d(430,280,460,300,UNCLICKED,"pi",0); // Box Of PhiFunction
button_3d(480,255,510,275,UNCLICKED,"-",0); // Box Of -
button_3d(515,255,545,275,UNCLICKED,"+",0); // Box Of +
button_3d(350,305,460,325,UNCLICKED,"=",0); // Box Of Equality
button_3d(480,305,545,325,UNCLICKED,"shift",BLUE); // Box Of shift
button_3d(480,280,510,300,UNCLICKED,"sqrt",0); //Box of x^n
button_3d(515,280,545,300,UNCLICKED,"inv",0); //box of 1/x
button_3d(100,205,150,230,UNCLICKED,"Sin",0); // Box OfSin Function
button_3d(160,205,210,230,UNCLICKED,"Cos",0); // Box Of CosFunction
button_3d(220,205,270,230,UNCLICKED,"Tan",0); // Box Of Tan Function

button_3d(100,250,150,275,UNCLICKED,"sin^-1",0); // Box Of sin^-1
button_3d(160,250,210,275,UNCLICKED,"cos^-1",0); // Box Of cos^-1
button_3d(220,250,270,275,UNCLICKED,"tan^-1",0); // Box Of tan^-1
button_3d(100,300,150,325,UNCLICKED,"ln",0); // Box Of ln
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(BLUE);
settextstyle(2,0,4);
outtextxy(125,290,"e");
outtextxy(185,290,"10^x");
outtextxy(245,290,"x^3");
button_3d(160,300,210,325,UNCLICKED,"log",0); // Box Of log
button_3d(220,300,270,325,UNCLICKED,"x^2",0); // Box Of x^2
button_3d(100,350,150,370,UNCLICKED,"deg",15);
button_3d(160,350,210,370,UNCLICKED,"rad",0);
button_3d(220,350,270,370,UNCLICKED,"gra",0);
button_3d(480,350,545,370,UNCLICKED,"Off",4);

button_3d(350,350,380,370,UNCLICKED,"M+",0);
button_3d(390,350,420,370,UNCLICKED,"M-",0);
button_3d(430,350,460,370,UNCLICKED,"MR",0);




} // END OF FUNCTION void structure()
/*********************************************************/
/* */
/* Main starts here */
/* */
/*********************************************************/
void main()
{
clrscr();
double y=0,z=0,pnt,pnt1=0,x=0,r=0;
int gdriver = DETECT, gmode, errorcode;
int i;
// @@@@@@@@------very Important--------@@@@@@@
/*
********************************************************************
To start the graphics system, you must first call initgraph.
initgraph initializes the graphics system by loading
a graphics driver from disk (or validating a registered driver)
then putting the system into graphics mode.
initgraph also resets all graphics settings (color, palette, current
position, viewport, etc.) to their defaults.
********************************************************************
*/
initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
midx=getmaxx()/2;midy=getmaxy()/2;
structure();
gotoxy(row,col);
printf("\t\t\t\t\t");
gotoxy(row,col);
printf("0");
// @@@@@@@@------Important--------@@@@@@@
mem=(float*)malloc(y*sizeof(float));
while( ch!=27&&ch1!=27) //While Escape is not pressed
{ //and if base is not 10
pnt1=0;//no doubleing point entered Yet
ch2='0';
while(ch2!=27)
//a=0 means that no no. has been entered yet
{
if(bflagp!='u')
{
dummy=input();
if(dummy!='o')
{
gotoxy(row,col);
printf("The trail version does not support this feature");
input();
gotoxy(row,col);
printf("\t\t\t\t\t\t");
}
y=0;z=0;ch='0';
gotoxy(row,col);
printf("\t\t\t\t\t\t");
gotoxy(row,col);
printf("0");

}

ch=input();
if(ch=='>'||ch=='<'||ch=='?')
{
sflag=0;
if(ch=='>'){ //M+
*mem+=y;
}
if(ch=='<'){ //M-
*mem-=y;
}
if(ch=='?') //MR
{
y=*mem;
gotoxy(row,col);
printf("\t\t\t\t\t\t");
gotoxy(row,col);
printf("%g",y);
}
if(*mem==0){
mflag=0;
}
if(*mem!=0){
mflag=1;
}
}
if(mflag==0)
{
gotoxy(row,7);
printf(" ");
}
if(mflag!=0)
{
gotoxy(row,7);
printf("M");
}
gotoxy(row,col);
if(ch=='a')
{ sflag=0;
y=0;
gotoxy(row,col);
printf("\t\t\t\t\t");
gotoxy(row,col);
printf("0");
}
if(ch=='o')
//for clearing the screen of the calculater
{
sflag=0;
y=0;z=0;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("0");
gotoxy(row,col);
break;
}
if(ch=='q')
{
sflag=0;
y=sqrt(y);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",y);
}
if(ch=='m')
{
sflag=0;
y=1/y;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",y);
}
if(ch=='+'||ch=='-'||ch=='/'||ch=='\\'||ch=='='||ch=='*')
{
sflag=0;
break;
}
if(ch=='.') //case for a decimal point
{
sflag=0;
if(pnt1==0) //ie no decimal has been entered yet
{
gotoxy(row,col);
printf("\t\t\t\t ");// double
gotoxy(row,col);
printf("%g.",y);
pnt1=.1; //ie: one decimal point no has been entered
continue; //go back to the begining and get the next number
}
else //decimal point has alredy been entered and thus no change in the screen
{
sflag=0;
continue; //go back to the begining
}
}//out of the '.' condition
if(pnt1!=0) //ie we have a doubleing point
{ sflag=0;
if(ch<='9'&&ch>='0') //input integer
{
x=(double)ch;//type cast the character into double to perforn further
operations
x-=48; //since character digit indoubleing -48 gives the corresponding ASCII
x=x*pnt1; //make it a decimal
y=x+y; //add it in result
pnt1*=.1; //shift to the second doubleing point
gotoxy(row,col);
printf("%g",y);
gotoxy(row,col);
continue; //back to the top
}
}
//if no decimal point number then proceed
if(ch<='9'&&ch>='0')
{ sflag=0;
x=(double)ch; //typecast to double
x-=48; //get corresponding ASCII
y=(y*10)+x; //add to right of result
gotoxy(row,col); //go back to start of the calc screen
printf("\t\t\t\t "); //clear the screen
gotoxy(row,col);
printf("%g",y); //print the number
}
if(ch=='u'||ch=='v'||ch=='w'||ch=='x')
{ sflag=0;
if(bflagp==bflag&&bflag=='u')
{
continue;
}
else
{
basecng(y,pnt1);
}
}
if(ch=='d'||ch=='r'||ch=='g')
{
sflag=0;
y=angle_conv(y);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",y);
}
if(ch=='s'||ch=='c'||ch=='t'||ch=='i'||ch=='j'||ch=='k'||ch=='n'||ch=='l'||ch=='p'||ch=='h')
//ie the user opted for a function
{
if(ch=='s'||ch=='c'||ch=='t') //sin /cos/tan
{
sflag=0;
if(flag!='r')
{
flagp=flag;
flag='r';
y=angle_conv(y);
flag=flagp;
}
switch(ch)
{
case 's': y=sin(y); break;
case 'c': y=cos(y); break;
case 't': y=tan(y); break;
}
}
if(ch=='i'||ch=='j'||ch=='k')
{
sflag=0;
if(flag!='r')
{
flagp='r';
}
switch(ch)
{
case 'i': y=asin(y); break;
case 'j': y=acos(y); break;
case 'k': y=atan(y); break;
}
if(flag!='r')
{
y=angle_conv(y);
}
}
else if(ch=='n')
{
if(sflag==1)
{
y=exp(y);
sflag=0;
}
else
y=log(y); //ln
}
else if(ch=='l')
{
if(sflag==1)
{
y=pow(10,y);
sflag=0;
}
else
y=log10(y); //log
}
else if(ch=='p')
{
if(sflag==1)
{
y=pow(y,3);
sflag=0;
}
else
y=pow(y,2); //square
}
else if(ch=='h')
{
sflag=0;
y=PI; //pi
}
gotoxy(row,col);
printf("\t\t\t\t ");//Clear the screen
gotoxy(row,col);
printf("%g",y);
}//else condition
}//out of second condition ie we now have the first no. or function or
operater
for(;ch!=27&&ch1!='='&&ch!='=';)//ie the characters input are not ESCAPE or
Equal to
{
pnt1=0;z=0;
if(ch=='o'||ch1=='o') // For Clear The Screen
{
sflag=0;
y=0;z=0;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("0");
gotoxy(row,col);
break;
}
for(;ch1!=27;)
{
gotoxy(row,col);
ch1=input();
if(ch1=='>'||ch1=='<'||ch1=='?')
{
if(ch1=='>') //M+
*mem+=z;
if(ch1=='<') //M-
*mem-=z;
if(ch1=='?') //MR
{
z=*mem;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
}
if(*mem==0)
mflag=0;
if(*mem!=0)
mflag=1;
}
if(mflag==0)
{
gotoxy(row,7);
printf(" ");
}
if(mflag!=0)
{
gotoxy(row,7);
printf("M");
}
gotoxy(row,col);

if(ch1=='a')
{
z=0;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("0");
}
if(ch=='o'||ch1=='o') // For Clear The Screen
{
y=0;z=0;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("0");
gotoxy(row,col);
break;
}
if(ch1=='q')
{
z=sqrt(z);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
}
if(ch1=='m')
{
z=1/z;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
}
if(ch1=='.')
{
if(pnt1==0)
{
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g.",z);
pnt1=.1;
continue;
}
else
{
continue;
}
}
if(pnt1!=0)
{
if(ch1<='9'&&ch1>='0')
{
x=(double)ch1;
x-=48;
x=x*pnt1;
z=x+z;
pnt1=pnt1*.1;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
continue;
}
}
if(ch1=='+'||ch1=='-'||ch1=='*'||ch1=='/'||ch1=='=')
break;
if(ch1>='0'&&ch1<='9')
{
x=(double)ch1;
x=x-48;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
z=(z*10)+x;
printf("%g",z);
}
if(ch=='u')
if(ch=='d'||ch=='r'||ch=='g')
{
z=angle_conv(z);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
}
if(ch1=='s'||ch1=='c'||ch1=='t'||ch1=='i'||ch1=='j'||ch1=='k'||ch1=='n'||ch1=='l'||ch1=='p'||ch1=='h')
//ie the user opted for a function
{
if(ch1=='s'||ch1=='c'||ch1=='t') //sin
{
if(flag!='r')
{
flagp=flag;
flag='r';
angle_conv(z);
flag=flagp;
}
switch(ch1)
{
case 's': z=sin(z); break;
case 'c': z=cos(z); break;
case 't': z=tan(z); break;
}
}
if(ch1=='i'||ch1=='j'||ch1=='k')
{
if(flag!='r')
{
flagp='r';
}
switch(ch1)
{
case 'i': z=asin(z); break;
case 'j': z=acos(z); break;
case 'k': z=atan(z); break;
}
z=angle_conv(z);
}
else if(ch1=='l')
{
z=log10(z); //log
}
else if(ch1=='p')
{
z=pow(z,2); //square
}
else if(ch1=='h')
{
z=PI; //pi
}
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",z);
gotoxy(row,col);
}
}
if(ch1=='+'||ch1=='-'||ch1=='=')
{
y=add(y,z,ch);
if(ch2!='0')
{
y=add(r,y,ch2);
ch2='0';
}
}
else
{
if(ch=='*'||ch=='/')
y=add(y,z,ch);
else
{
ch2=ch;
r=y;
y=z;
}
}
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",y);
ch=ch1;
ch1='0';
if(ch=='='||ch1=='=')
break;
}
if(ch=='o'||ch1=='o') // For Clear The Screen
{ y=0;z=0;
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("0");
gotoxy(row,col);
continue;
}
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%g",y);
z=0;
}

closegraph();
remove_mouse();
exit(0);
}




/*************************************************************/
/* */
/* This function gets the user's Input */
/* */
/*************************************************************/
char input()
{
X=0;Y=0;
char ch;
show_mouse();
if(bflag!='u')
{
button_3d(108,140,208,160,UNCLICKED,"DEC",15);
button_3d(218,140,318,160,UNCLICKED,"OCT",0);
button_3d(328,140,428,160,UNCLICKED,"HEX",0);
button_3d(438,140,538,160,UNCLICKED,"BIN",0);
bflag='u';
}
do
{
mouse();
if (X>=350 && X<=380 && Y>=205 && Y<=225) // Condition For 7
{
hide_mouse();
button_3d(350,205,380,225,CLICKED,"7",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,205,380,225,UNCLICKED,"7",0);
show_mouse();
ch='7';
return ch;
}

//**********************************************
if (X>=390 && X<=420 && Y>=205 && Y<=225) // Condition For 8
{
hide_mouse();
button_3d(390,205,420,225,CLICKED,"8",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(390,205,420,225,UNCLICKED,"8",0);
show_mouse();
ch='8';
return ch;
}

//*****************************************
if (X>=430 && X<=460 && Y>=205 && Y<=225) // Condition For 9
{
hide_mouse();
button_3d(430,205,460,225,CLICKED,"9",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(430,205,460,225,UNCLICKED,"9",0);
show_mouse();
ch='9';
return ch;
}

//***********************************
if (X>=350 && X<=380 && Y>=230 && Y<=250) // Condition For 4
{
hide_mouse();
button_3d(350,230,380,250,CLICKED,"4",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,230,380,250,UNCLICKED,"4",0);
show_mouse();
ch='4';
return ch;
}

//***********************************
if (X>=390 && X<=420 && Y>=230 && Y<=250) // Condition For 5
{
hide_mouse();
button_3d(390,230,420,250,CLICKED,"5",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(390,230,420,250,UNCLICKED,"5",0);
show_mouse();
ch='5';
return ch;
}

//***********************************
if (X>=430 && X<=460 && Y>=230 && Y<=250) // Condition For 6
{
hide_mouse();
button_3d(430,230,460,250,CLICKED,"6",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(430,230,460,250,UNCLICKED,"6",0);
show_mouse();
ch='6';
return ch;
}

//***********************************
if (X>=480 && X<=510 && Y>=230 && Y<=250) // Condition For *
{
hide_mouse();
button_3d(480,230,510,250,CLICKED,"*",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(480,230,510,250,UNCLICKED,"*",0);
show_mouse();
ch='*';
return ch;
}
//***********************************
if (X>=515 && X<=545 && Y>=230 && Y<=250) // Condition For /
{
hide_mouse();
button_3d(515,230,545,250,CLICKED,"/",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(515,230,545,250,UNCLICKED,"/",0);
show_mouse();
ch='/';
return ch;
}
//***********************************
int a,b;
if (X>=350 && X<=380 && Y>=255 && Y<=275) // Condition For 1
{
hide_mouse();
button_3d(350,255,380,275,CLICKED,"1",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,255,380,275,UNCLICKED,"1",0);
show_mouse();
ch='1';
return ch;
}
// *************************************
if (X>=390 && X<=420 && Y>=255 && Y<=275) // Condition For 2
{
hide_mouse();
button_3d(390,255,420,275,CLICKED,"2",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(390,255,420,275,UNCLICKED,"2",0);
show_mouse();
ch='2';
return ch;
}
// *************************************
if (X>=430 && X<=460 && Y>=255 && Y<=275) // Condition For 3
{
hide_mouse();
button_3d(430,255,460,275,CLICKED,"3",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(430,255,460,275,UNCLICKED,"3",0);
show_mouse();
ch='3';
return ch;
}
// *************************************
if (X>=350 && X<=380 && Y>=280 && Y<=300) // Condition For 0
{
hide_mouse();
button_3d(350,280,380,300,CLICKED,"0",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,280,380,300,UNCLICKED,"0",0);
show_mouse();
ch='0';
return ch;
}
// *************************************
if (X>=390 && X<=420 && Y>=280 && Y<=300) // Condition For .
{
hide_mouse();
button_3d(390,280,420,300,CLICKED,".",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(390,280,420,300,UNCLICKED,".",0);
show_mouse();
ch='.';
return ch;
}
//**********************************************
if (X>=430 && X<=460 && Y>=280 && Y<=300) // Condition For pi
{
hide_mouse();
button_3d(430,280,460,300,CLICKED,"pi",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(430,280,460,300,UNCLICKED,"pi",0);
show_mouse();
ch='h';
return ch;
}
//***********************************************
if (X>=480 && X<=510 && Y>=255 && Y<=275) // Condition For -
{
hide_mouse();
button_3d(480,255,510,275,CLICKED,"-",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(480,255,510,275,UNCLICKED,"-",0);
show_mouse();
ch='-';
return ch;
}
//**************************************************
if (X>=515 && X<=545 && Y>=255 && Y<=275) // Condition For +
{
hide_mouse();
button_3d(515,255,545,275,CLICKED,"+",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(515,255,545,275,UNCLICKED,"+",0);
show_mouse();
ch='+';
return ch;
}
//*****************************************************
if (X>=350 && X<=460 && Y>=305 && Y<=325) // Condition For =
{
hide_mouse();
button_3d(350,305,460,325,CLICKED,"=",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,305,460,325,UNCLICKED,"=",0);
show_mouse();
ch='=';
return ch;
}
//*****************************************************
if (X>=480 && X<=545 && Y>=305 && Y<=325) // Condition For shift
{
hide_mouse();
button_3d(480,305,545,325,CLICKED,"shift",BLUE);
show_mouse();
delay(250);
hide_mouse();
button_3d(480,305,545,325,UNCLICKED,"shift",BLUE);
show_mouse();
ch='~';
sflag=1;
return ch;
}

//*************************************
if (X>=480 && X<=510 && Y>=205 && Y<=225) // Condition For AC
{
hide_mouse();
button_3d(480,205,510,225,CLICKED,"AC",4);
show_mouse();
delay(250);
hide_mouse();
button_3d(480,205,510,225,UNCLICKED,"AC",4);
show_mouse();
ch='o';
return ch;
}
/********************C*/
if (X>=515 && X<=545 && Y>=205 && Y<=225) // Condition For C
{
hide_mouse();
button_3d(515,205,545,225,CLICKED,"CE",4);
show_mouse();
delay(250);
hide_mouse();
button_3d(515,205,545,225,UNCLICKED,"CE",4);
show_mouse();
ch='a';
return ch;
}
// ****************************************
if (X>=100 && X<=150 && Y>=205 && Y<=230) // Condition For Sin
{
hide_mouse();
button_3d(100,205,150,230,CLICKED,"Sin",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(100,205,150,230,UNCLICKED,"Sin",0);
show_mouse();
ch='s';
return ch;
}
//***********************************
if (X>=160 && X<=210 && Y>=205 && Y<=230) // Condition For Cos
{
hide_mouse();
button_3d(160,205,210,230,CLICKED,"Cos",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(160,205,210,230,UNCLICKED,"Cos",0);
show_mouse();
ch='c';
return ch;
}
//***********************************
if(X>=515&&X<=545&&Y>=280&&Y<=300) //inverse
{
hide_mouse();
button_3d(515,280,545,300,CLICKED,"inv",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(515,280,545,300,UNCLICKED,"inv",0);
show_mouse();
ch='m';
return ch;
}

if (X>=220 && X<=270 && Y>=205 && Y<=230) // Condition For Tan
{
hide_mouse();
button_3d(220,205,270,230,CLICKED,"Tan",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(220,205,270,230,UNCLICKED,"Tan",0);
show_mouse();
ch='t';
return ch;
}
//*********************************** */

if (X>=100 && X<=150 && Y>=250 && Y<=275) // Condition For sin^-1
{
hide_mouse();
button_3d(100,250,150,275,CLICKED,"sin^-1",0);
show_mouse();
delay(150);
hide_mouse();
button_3d(100,250,150,275,UNCLICKED,"sin^-1",0);
show_mouse();
ch='i';
return ch;
}
//**************************
if (X>=160 && X<=210 && Y>=250 && Y<=275) // Condition For cos^-1
{
hide_mouse();
button_3d(160,250,210,275,CLICKED,"cos^-1",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(160,250,210,275,UNCLICKED,"cos^-1",0);
show_mouse();
ch='j';
return ch;
}
//**************************
if (X>=430 && X<=460 && Y>=350 && Y<=370) // Condition For MR
{
hide_mouse();
button_3d(430,350,460,370,CLICKED,"MR",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(430,350,460,370,UNCLICKED,"MR",0);
show_mouse();
ch='?';
return ch;
}
if (X>=390 && X<=420 && Y>=350 && Y<=370) // Condition For M-
{
hide_mouse();
button_3d(390,350,420,370,CLICKED,"M-",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(390,350,420,370,UNCLICKED,"M-",0);
show_mouse();
ch='<';
return ch;
}
if (X>=350 && X<=380 && Y>=350 && Y<=370) // Condition For M+
{
hide_mouse();
button_3d(350,350,380,370,CLICKED,"M+",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(350,350,380,370,UNCLICKED,"M+",0);
show_mouse();
ch='>';
return ch;
}
if (X>=220 && X<=270 && Y>=250 && Y<=275) // Condition For tan^-1
{
hide_mouse();
button_3d(220,250,270,275,CLICKED,"tan^-1",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(220,250,270,275,UNCLICKED,"tan^-1",0);
show_mouse();
ch='k';
return ch;
}
//**************************

if (X>=100 && X<=150 && Y>=300 && Y<=325) // Condition For ln
{
hide_mouse();
button_3d(100,300,150,325,CLICKED,"ln",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(100,300,150,325,UNCLICKED,"ln",0);
show_mouse();
ch='n';
return ch;
}
//**************************
if (X>=160 && X<=210 && Y>=300 && Y<=325) // Condition For log
{
hide_mouse();
button_3d(160,300,210,325,CLICKED,"log",0);
show_mouse();
delay(150);
hide_mouse();
button_3d(160,300,210,325,UNCLICKED,"log",0);
show_mouse();
ch='l';
return ch;
}
//**************************
if (X>=220 && X<=270 && Y>=300 && Y<=325) // Condition For X^2
{
hide_mouse();
button_3d(220,300,270,325,CLICKED,"x^2",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(220,300,270,325,UNCLICKED,"x^2",0);
show_mouse();
ch='p';
return ch;
}
if (X>=100 && X<=150 && Y>=350 && Y<=370) // Condition For deg
{
hide_mouse();
button_3d(100,350,150,370,CLICKED,"deg",15);
button_3d(160,350,210,370,UNCLICKED,"rad",0);
button_3d(220,350,270,370,UNCLICKED,"gra",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(100,350,150,370,UNCLICKED,"deg",15);
show_mouse();
ch='d';
flagp=flag;
flag=ch;
return ch;
} //**************************
if (X>=160 && X<=210 && Y>=350 && Y<=370) // Condition For rad
{
hide_mouse();
button_3d(100,350,150,370,UNCLICKED,"deg",0);
button_3d(160,350,210,370,CLICKED,"rad",15);
button_3d(220,350,270,370,UNCLICKED,"gra",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(160,350,210,370,UNCLICKED,"rad",15);
show_mouse();
ch='r';
flagp=flag;
flag=ch;
return ch;
}
if (X>=220 && X<=270 && Y>=350 && Y<=370) // Condition For gra
{
hide_mouse();
button_3d(100,350,150,370,UNCLICKED,"deg",0);
button_3d(160,350,210,370,UNCLICKED,"rad",0);
button_3d(220,350,270,370,CLICKED,"gra",15);
show_mouse();
delay(250);
hide_mouse();
button_3d(220,350,270,370,UNCLICKED,"gra",15);
show_mouse();
ch='g';
flagp=flag;
flag=ch;
return ch;
}
if ((X>=480 && X<=545 &&Y>=350 &&Y <=370)||(X>=575&&X<=595&&Y>=23&&Y<=40))
//OFF
{
free(mem);
exit(0);
}
if (X>=108 && X<=208 && Y>=140 && Y<=160) // Condition For dec
{
hide_mouse();
button_3d(108,140,208,160,CLICKED,"DEC",15);
button_3d(218,140,318,160,UNCLICKED,"OCT",0);
button_3d(328,140,428,160,UNCLICKED,"HEX",0);
button_3d(438,140,538,160,UNCLICKED,"BIN",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(108,140,208,160,UNCLICKED,"DEC",15);
show_mouse();
ch='u';
bflagp=bflag;
bflag=ch;
return ch;
}
if (X>=218 && X<=318 && Y>=140 && Y<=160) // Condition For oct
{
hide_mouse();
button_3d(108,140,208,160,UNCLICKED,"DEC",0);
button_3d(218,140,318,160,CLICKED,"OCT",15);
button_3d(328,140,428,160,UNCLICKED,"HEX",0);
button_3d(438,140,538,160,UNCLICKED,"BIN",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(218,140,318,160,UNCLICKED,"OCT",15);
show_mouse();
ch='v';
bflagp=bflag;
bflag=ch;
return ch;
}
if (X>=328 && X<=428 && Y>=140 && Y<=160) // Condition For hex
{
hide_mouse();
button_3d(108,140,208,160,UNCLICKED,"DEC",0);
button_3d(218,140,318,160,UNCLICKED,"OCT",0);
button_3d(328,140,428,160,CLICKED,"HEX",15);
button_3d(438,140,538,160,UNCLICKED,"BIN",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(328,140,428,160,UNCLICKED,"HEX",15);
show_mouse();
ch='w';
bflagp=bflag;
bflag=ch;
return ch;
}
if (X>=438 && X<=538 && Y>=140 && Y<=160) // Condition For dec
{
hide_mouse();
button_3d(108,140,208,160,UNCLICKED,"DEC",0);
button_3d(218,140,318,160,UNCLICKED,"OCT",0);
button_3d(328,140,428,160,UNCLICKED,"HEX",0);
button_3d(438,140,538,160,CLICKED,"BIN",15);
show_mouse();
delay(250);
hide_mouse();
button_3d(438,140,538,160,UNCLICKED,"BIN",15);
show_mouse();
ch='x';
bflagp=bflag;
bflag=ch;
return ch;
}
if(X>=480&&X<=510&&Y>=280&&Y<=300)
{
hide_mouse();
button_3d(480,280,510,300,CLICKED,"sqrt",0);
show_mouse();
delay(250);
hide_mouse();
button_3d(480,280,510,300,UNCLICKED,"sqrt",0);
show_mouse();
ch='q';
return ch;
}
/*
kbhit(void) function checks to see
if any key is currently pressed by the user
*/
}while(kbhit() == 0);
ch=getch();
return ch;
} //END OF FUNCTION char input()
/*************************************************************************/
/* */
/* This function performs the Calculations */
/* */
/*************************************************************************/
double add(double x,double y,char ch)
{
switch(ch)
{
case '+':
y=x+y;
break;
case '-':
y=x-y;
break;
case '*':
y=x*y;
break;
case '/':
y=x/y;
}
return y;
} //ENF OF FUNCTION double add(double x,double y,char ch)
double angle_conv(double no)
{
if(flagp=='d')
{
if(flag=='r')
{
no=no*PI/180;
}
if(flag=='g')
{
no=no*1.1111111;
}
}
else if(flagp=='r')
{
if(flag=='d')
{
no=no*180/PI;
}
if(flag=='g')
{
no=no*180/PI*1.1111111;
}
}
else if(flagp=='g')
{
if(flag=='r')
{
no=no/(180*1.1111111)*PI;
}
if(flag=='d')
{
no=no/1.1111111;
}
}
return(no);
}//END OF FUNCTION double angle_conv(double no)

void basecng(double y,double pnt1)
{
char str[17];
if(pnt1!=0)
{
gotoxy(row,col);
printf("The version does not support this feature");
getch();
bflag='u';
bflagp='0';
/*@@@@@@@@@@-----Important-----@@@@@@@@@
*/
main();
}
if(bflagp!='u')
{
gotoxy(row,col);
printf("The version does not support this feature ");
getch();
bflagp='0';
bflag='u';
/*
@@@@@@@@@@-----Important-----@@@@@@@@@
*/
main();
}
switch(bflag)
{
case 'v':
itoa(y,str,8);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%s",str);
bflagp='0';
break;
case 'w':
itoa(y,str,16);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%s",str);
bflagp='0';
break;
case 'x':
itoa(y,str,2);
gotoxy(row,col);
printf("\t\t\t\t ");
gotoxy(row,col);
printf("%s",str);
bflagp='0';
break;
}
bflag='u';
} // END OF FUNCTION void basecng(double y,double pnt1)

Note : For more information, you can also visit my other blogs. And don't forget to give your valuable comments.