Sunday 5 October 2014

Mes solution

 i)At what ROM location do we store the first opcode of an 8051 program? 
ans 000H       
ii) Explain the CJNC and JB instruction with eg.

click here for answer



click here for answer

                        
c. What is the difference between semaphore and mutex?
refer book
                                                    
a)  Write a program to perform the following                                                                       
i)                    Keep monitoring the P1.2 bit until it becomes high.
ii)                  When P1.2 becomes high, write value 45H to port 0 and
iii)                Send a high-to-low(H-to-L) pulse to P2.3     

click here for answer



b)      Explain addressing modes used in 8051.   

Refer book                                                                       
Explain the various task scheduling algorithms.                   
  i) State the contents of memory locations 200H – 205H for the following            
ORG 200H
MYDATA:   DB  “ABC123”        

Ans 200H - “A” , 201H- “B”, 202H- “C”, 203H- “1”, 204H- “2”, 205H-”3”   

                
  ii) Find the CY and AC flag bits for the following code
MOV A,#0FFH
ADD A,#01

answer MOV A, #00, ADD A, #0FFh
CY=0  


b.         Explain Assembler directives of the 8051.                                                                 
c.         Explain different states of a task.                                                                               
a)         Explain the following instructions                                                                             
i)  DA  ii) CJNC   iii) CPL              
                                                                                       
b)         Write a program to transfer the message “YES” serially at 9600 baud, 8-bit data,   
1 stop bit. Do this continuously.       

Click here for answer   

            c)         Explain the use of message queues, mailboxes and pipes. 

Write a program to transfer the message “YES” serially at 9600 baud, 8-bit data, 1 stop bit. Do this continuously.

MOV  TMOD,#20H             ;timer 1, mode 2
MOV  TH1,#-3                    ;9600 baud
MOV  SCON,#50H
SETB TR1
AGAIN:  MOV  A,#”Y”                        ;transfer “Y”
ACALL TRANS
MOV  A,#”E”                       ;transfer “E”
ACALL TRANS
MOV  A,#”S” ;transfer “S”
ACALL TRANS

SJMP AGAIN                       ;keep doing it

CJNE and JB

CJNE
Function:
Compare and Jump If Not Equal
Syntax:
CJNE operand1,operand2,reladdr

Instructions
OpCode
Bytes
Flags
CJNE A,#data,reladdr
0xB4
3
C
CJNE A,iram addr,reladdr
0xB5
3
C
CJNE @R0,#data,reladdr
0xB6
3
C
CJNE @R1,#data,reladdr
0xB7
3
C
CJNE R0,#data,reladdr
0xB8
3
C
CJNE R1,#data,reladdr
0xB9
3
C
CJNE R2,#data,reladdr
0xBA
3
C
CJNE R3,#data,reladdr
0xBB
3
C
CJNE R4,#data,reladdr
0xBC
3
C
CJNE R5,#data,reladdr
0xBD
3
C
CJNE R6,#data,reladdr
0xBE
3
C
CJNE R7,#data,reladdr
0xBF
3
C
Description: CJNE compares the value of operand1 and operand2 and branches to the indicated relative address if operand1 and operand2 are not equal. If the two operands are equal program flow continues with the instruction following the CJNE instruction.
The Carry bit (C) is set if operand1 is less than operand2, otherwise it is cleared.


Instruction Set: JB
JB
Function:
Jump if Bit Set
Syntax:
JB bit addrreladdr

Instructions
OpCode
Bytes
Flags
JB bit addr,reladdr
0x20
3
None

Description: JB branches to the address indicated by reladdr if the bit indicated by bit addr is set. If the bit is not set program execution continues with the instruction following the JB instruction.

i) Keep monitoring the P1.2 bit until it becomes high. ii) When P1.2 becomes high, write value 45H to port 0 and iii) Send a high-to-low(H-to-L) pulse to P2.


      SETB P1.2      ;make P1.2 an input
      MOV  A,#45H    ;A=45H
AGAIN:JNB  P1.2,AGAIN;get out when P.2=1
      MOV  P0,A      ;issue A to P0
      SETB P2.3      ;make P2.3 high

      CLR  P2.3      ;make P2.3 low for H-to-L

Saturday 4 October 2014

Discuss the effect of roughness parameter on friction factor. [5 Marks]


  • In turbulent flow rough pipe leads to a larger friction factor than the smooth pipes for given Reynold’s number.

  • If a rough pipe is smooth, the friction factor is reduced and ultimately a stage will come when further smoothing of the pipe does not reduce the friction factor for given Reynold’s number, the pipe is said to be hydraulically smooth.

  • The height of a single unit of roughness is denoted by K and is called roughness parameter.

  • The relative roughness is the ratio of the roughness parameter to the diameter of pipe, i.e. K/D the dependency of friction factor on the surface roughness is given through relative roughness.

  • For larger values of Reynold’s number (NRe < 2100) the friction factor is independent of the surface roughness.<div>


  • For low values of Reynold’s number (NRe > 2500) the friction factor is also function of surface roughness.

  • At very large values of Reynold’s number, the friction factor is independent of NRe but is a function of surface roughness.


Describe the use of friction factor chart. [5 Marks]


  • It is a logarithmic plot of friction factor as a function of the Reynold’s number over a wide range of the Reynold’s number for a flow in smooth as well as rough pipes.

  • The data for the plot are variable such as velocity, density and pipe diameter, etc. using liquids and gases.

  • This chart is termed as friction factor chart, Reynold’s number correlation chart and Moody diagram.

  • The friction factor is a function of both the Reynold’s number and relative roughness.

  • For laminar flow region the friction factor is only the function of Reynold’s number therefore only one line is shown for Reynold’s number upto 2100.

  • For laminar flow region equition $ \f = {16}/{\N_{\R}} $ relates the friction factor to Reynold’s number and the above equation is the equation of straight line having slope minus one.

  • For turbulent flow the lowest line represents the friction factor for smooth tubes the move convenient empirical equation for this line is $ \f = 0.046\ \N_{\R}^{-0.2} $ . This applies over the Range of Reynold’s numbers from 50,000 to 1 × $ 10^6 $ , another equation applicable over range $ 3 \× 10^6 $ is $ \f = 0.0014 + {0.125}/{\N_{\R}^{0.32}} $ .

  • It is clear from the figure that the friction factor is low for smooth pipe as compared to rough pipe and increases as the relative roughness increases for given Reynold’s number.

**The Uses of friction factor chart** > > * Knowledge of volumetric flow rate, density of fluid, viscosity of fluid and pipe diameter. The Reynold's number is calculated. The Reynold's number is used as abscissa and friction factor is read as ordinate. > > * Friction factor is then used in appropriate equation to calculate the head losses due to friction from known pipe size and flow rate. > > * The friction factor is also used to calculate the skin friction which then can be combined with the other forms of friction to get total friction losses in entire flow system. >

Write short note on Power curve in mixing and agitation.


An empirical correlation of the power (or power number) with other variables of a system permits fairly accurate prediction of the requirement of a given impeller to rotate at a given speed. Such correlations can be obtained by using a method of dimensional analysis. The power requirement of the impeller is a functional of geometrical details of the impeller and vessel, the viscosity and the density of liquid, and the rotational speed of impeller. > > An empirical correlation that can be obtained for a given system from the dimensional analysis has the form as : >

${\P}/{\N^3 \D\a^5 \ρ} = \f ({\ND\a^2 \ρ}/{\μ} , {\N^2\D_\a}/{\ρ})$ —(1) > >

where ${\P}/{\N^3 \d\a^5 \ρ}$ is the power number $(\N\P)$, —(2)

${\ND\a^2 \ρ}/{\μ}$ is the impeller Reynold’s number $(\N{\Re})$, —(3)

${\N^2\D\a}/{\ρ}$ is the Froude number $(\N{\Fr})$, —(4)

N = Rotational speed in revolution per second, $\D_\a$ = Diameter of impeller, ρ = Density of fluid,
and μ = Viscosity of fluid. When $\N_{\Re} > 10,000$, the flow in the vessel is turbulent and when $\N_{\Re} < 10$, the flow is laminar For $\N_{\Re}$ between 10 and 10,000 the flow is in a transition region in which the flow is turbulent at the impeller and laminar in remote parts of the vessel. Equation (1) is also written as : $\N_\P = \f(\N_{\Re}, \N_{\Fr})$     ---(5) The Froude number, $\N_{\Fr}$represents the influence of gravitation and effects the power consumption only when vortex is present. If the speed of impeller is increased, in unbaffled vessels, the centrifugal force acting in the liquid causes the free surface of the liquid to assume a paraboloid form by raising the liquid level at the wall and lowering the level at the shaft. This is called _vortex._ The vortex is avoided by use of baffles. For Reynold's number < 300, vortex may not be observed even for the unbaffled vessel. The Reynold's number accounts for viscous forces and in agitated vessels, as usually the case, the viscous forces are significant. Thus, equation (5) reduces to $\N_\P = \f (\N_{\Re})$     ---(6)

The power consumption is related to the density and the viscosity of the liquid, the rotational speed, and the impeller diameter by plotting power as a functional of Reynold’s number.

At lower Reynold’s number (laminar flow), the relationship between $\N\P$ and $\N{\Re}$ may be given as

$\N\P = {\C0}/{\N_{\Re}}$ —(7)

where $\C_0$ is a constant for a given impeller and given geometrical details.

Rearranging equation (7), we get

$\N\P . \N{\Re} = \C_0$ —(8)

Substituting the values of $\N\p$ and $\N{\Re}$ in equation (8), we get

$\P = \C0 \μ \D\a^3 \N^2$ —(9)

Equation (9) indicates that if the speed is doubled, power consumption will increase by a factor of four.

For higher values of $\N_{\Re}$, the Froude number plays an important part. In this case, power number is constant i.e.

$\N_\p = \Constant = \C’$ —(10)

$\P = \C’ \ρ \D_\a^5 \N^3$ —(11)

Equation (11) indicates that if the speed is doubled, the power consumption increases by factor of eight in the turbulent flow region.




Curve 1 : Curve blade turbine, 4 baffles each width of baffle $\D\T ⁄ 12, \D\T -$tank diameter.

Curve 2 : Open straight blade (six blade) turbine four baffles each $\D_\T ⁄12.$

Curve 3 : Pitched blade turbine, 4 baffles each $\D_\T ⁄ 12$.

Curve 4 : Propeller, four baffles each 0.1 $\D\T$. Pitch = $2 \D\a$.

Curve 5 : Propeller, four baffles each 0.1 $\D\T$. pitch = $\D\a$.

</div>

List out different types of values used in industries along with their functions. [10 Marks]


> * **Globe Valve : ** Refer figure below.
> 1. The globe valve is used to control the flow but pressure drop across the globe valve is more that that in gate valve. > > 2. Globe valves are preferably installed with high pressure side connected to the top of the disk. > > 3. In y-type globe valves, the stem seat are at about 48° to the pipe instead of 90°. > > 4. **Material of Construction : ** Forged steel, stainless steel, gun metal, bronze.

> > ![](https://itextbook-prod.s3.amazonaws.com/uploads/book_image/image/926/Question_6__a__2.png) > **
** > > **
** > * **Ball Valve : ** Refer figure below > ![](https://itextbook-prod.s3.amazonaws.com/uploads/book_image/image/927/Question_6__a__3.png) > **
** > >
> > 1. Ball valve is used for complete shut-off (on-off) service and operate through 90°. > > 2. The valve has a high degree of pressure recovery. > > 3. Valve size 1/8" to 48" with ends flanged screwed socket weld. > > 4. Pressure range upto 720 psi. Temperature range is 196° to 260° C. > > 5. Types : >
> (a) Fixed ball valve (Ball rotates on stem extension with bearing sealed with O-rings.) > > (b) Free ball valve (Ball is free to move axially). > > (c) Top-entry ball valve (Ball and seats are inserted from above.) > > (d) Split body valve. > > * **Needle valve : ** Refer figure below. > > ![](https://itextbook-prod.s3.amazonaws.com/uploads/book_image/image/928/Question_6__a__4.png) >
> >
> > 1. Needle valve is very similar to a globe valve except that it has a needle shaped disc. > > 2. This valve has a small opening which causes more pressure drop (than the globe value) but it is useful for correct flow regulation. > * **Butterfly Valve : ** Refer figure below. > ![](https://itextbook-prod.s3.amazonaws.com/uploads/book_image/image/1150/Question_5__a__4.png) >
> >
> > 1. Butterfly is a rotary-stem valve which operates on same principle as a damper in stove pipe. > > 2. The valve with all metal internals are widely used where leakage flow of about 1% of the maximum rating between disk and the body can be tolerated. > > 3. For tight shut-off service and elastometer linear are inserted in the body which are made of Buna N, Neopreme, Nordel and Viton. > > 4. Pressure range is upto 150 psi and temperature range upto 170 °C. > > 5. Size - 50 mm to 1200 mm. > > 6. Valve body is made of cast iron, steel, aluminium etc. > * **Check Valve or Non-Return Valve:**  Refer figure below.

> > ![](https://itextbook-prod.s3.amazonaws.com/uploads/book_image/image/940/Question_6__a__6.png) >
>
>
> > 1. Check Valves are used to get unidirectional flow or they prevent reversal of flow. > > 2. These are normally used in horizontal pipes, so that at the time of start or closing of valve, the gravity force is maximum and it becomes minimum at time of closing. >

For a turbine agitator installed in a vertical tank speed is 1.5 rps. Diameter of tank is 1.8 m and the diameter of turbine is 0.6 m. The density of liquid is 1120 kg/m3 and viscosity is 120 Ns/m2. If the power Number is given by Np = 65/NRe. Calculate the power required for agitation.


</div> > Diameter of tank, DT = 1.8 m > > Speed, N = 1.55 rps > > Diameter of turbine agitator, Da = 0.6 m > > Density of liquid, ρ = 1120 kg/m3 > > Viscosity of liquid, μ = 120 Ns/m2 = 120 kg/(m-s) > > ∴ Reynold’s number, Np = ${\D_a^2 \Nρ}/{μ} = {(0.6)^2 \× 1.5 \× 1120}/{120} = 5.04$
> > Power number, Np = ${65}/{N_{Re}} = {65}/{5.04}$ = 12.9 > > ∴ Power required, P = Np ρ N3 Da5 = 12.9 × 1120 × (1.5)3 × (0.6)5
> > = 3791 watt = 3.79 kW

Write short note on Cavitation.


**Cavitation:**
> > * The vapour pressure of a liquid may be defined as pressure at which the liquid will transform into vapour (liquid boils) at the given temperature and vapour pressure is function of temperature.
> > * Care should be taken that pressure at any point does not fall below the vapour pressure of liquid to be pumped.
> > * If pressure in the pumping system falls below vapour pressure of the liquid to be pumped, then some of the liquid flashes into vapour or if the liquid contains gases, they may come out of the solution resulting into gas pocket, that damage the impeller. This phenomena is known as _cavitation._
**Effect of Caviation** > > > * Sufficient suction head is not developed that results in on pumping of liquid.
> > * Mechanical damage to the pumps occurs as bubble collapse.
> > * Considerable noise and vibration is produced.
> > * Decrease efficiency of pump. How to Minimize Cavitation ? > > > * By keeping the velocity of liquid in the suction pipe as minimum as possible. > > * Avoid sharp bends in the suction pipe, that will reduce loss of head. > > * The cavitation will not take place, if the total head vapour pressure of liquid is water then the absolute pressure head should not be below 2.5 m of water. > > * Cavitation resistant material or coatings such as aluminium, bronze, stainless steel should be used. >

What is NPSH for pumps ? Derive general expression for its calculation. Differentiate between NPSH and NPSHR.


What is NPSH for pumps ? Derive general expression for its calculation. Differentiate between NPSH and NPSHR. [10 Marks]

NPSH (Net Positive Suction Head)
> > The term NPSH is very commonly used in pump industry. Actually minimum suction conditions are more specified in terms of NPSH. NPSH may be defined as the total head required to make the liquid flow through the suction pipe to the pump impeller, or it is the amount by which the absolute pressure available at the suction point is in excess or greater than vapour pressure of liquid at pumping temperature.
> > Poor suction due to inadequate NPSH leads to physical erosion, damage to the impeller and this damage can become so severe as to completely destroy the impeller and create excessive clearances in the casing. >

Expression for NPSH

For deriving the expression for NPSH, let us consider the pumping system shown in figure below.


>
Where $\Z\a$ and $\Z\b$ = Elevation of point A and B respectively, m

$\h{\SL}$ and $\h{\DL}$ = Friction losses for suction and discharge side of pump respectively, kgf-m/kg

W = Weight density of liquid = ρg

NPSh = (Absolute pressure head available at suction point A’) - (Vapour pressure head)

∴ NPSH = $({\V’\a^2}/{2\g} + {\P’\a}/{\W}) - {\P_\v}/{\W}$ —(1)

where $\P_\v$ = Vapour pressure of liquid to be pumped.

Applying Bernoulli equation between point A and A’.

$\Z\a + {\V’\a^2}/{2\g} + {\P\a}/{\W} = \Z\a’ + {\V’\a^2}/{2\g} + {\P’\a}/{\W} + \h_{\LS}$

Assuming $\Z\a = 0$ and $\V\α = 0$

$({\P’\a}/{\W} + {\V’\a^2}/{2\g}) = {\P\a}/{\W} - \h{\LS} - \Z’_\a$

Substituting this value for the bracketed quantity in equation (1) we get

NPSH = ${\P’\a}/{\W} - {\P\v}/{\W} - \h{\LS} - \Z’\a = {\P’\a - \P\v}/{\W} - \h{\LS} - \Z’\a$

If pump center-line is below the point A, then

NPSH = ${\P’\a - \P\v}/{\W} - \h{\LS} - \Z’\a$ —(2)

Or equation (2) can also be written as,

NPSH = ${\P’\a - \P\v}/{\ρ\g} - \h{\LS} - \Z’\a$ —(3)

Or in terms of energy per unit mass

NPSH = ${\P’\a - \P\v}/{\ρ} - \h{\LS} - \gZ’\a$ —(4)

where $\h{\LS}$ is in J/klg and $\gZ’\a$ is in J/kg.

Note : If NPSH = 0, suction pressure equals the vapour pressure and cavitation occurs. Thus NPSH must be greater than zero and is usually 2 meters or more.

NPSHA and NPSHR

  • For any pump installation a distinction is made between required NPSH (NPSHR) and the available NPSH (NPSHA).

  • The value of NPSHR is given by the pump manufacturer and this value can also be determine experimentally.

  • For determining its value, the pump is tested and minimum value of suction head is obtained at which the pump gives maximum efficiency without any noise. (i.e. cavitation free.)

  • The NPSHR varies with pump design, speed of pump and capacity of the pump.

  • In order to have cavitation free operation of centrifugal pump, the NPSHA should be greater than the NPSHR.

  • Generally NPSHR must be greater than 2 meters or more.


Characteristics Curves of Centrifugal Pumps


Characteristics Curves of Centrifugal Pumps > > Characteristics curves of centrifugal pumps are defined as those curves which are plotted from the results of a tests on the centrifugal pumps and these curves are necessary to predict the behavior and performance of the pump when the pump is working under different flow rate, head and speed. > > Main Characteristics Curves > > (a) This curves consist of variation of head (manometric head, Hm), power and discharge with respect to speed. > > (b) For plotting curves of Hm v/s N, Q is kept constant. We know that $√{h_m}$/DN is a constant or Hm α N2, this means the head developed by a pump is proportional to N2, hence the curve of Hm v/s N is a parabolic curve as shown in figure below. > > (c) For plotting curves of Q v/s N, Hm is kept constant. We know that, Q/D3N is constant, hence Q α N, this means that the curve Q v/s N is a straight line. > >
> > >

(d) For plotting curves of P v/s N. Hm and Q are kept constant. We know that P/D5N3 is a constant, hence P α N3. This means that curves P v/s N is a cubic curve as shown in Figure above. > > Operating Characteristics Curves
<div>
> > > >
<div> > 1. If the speed is kept constant, the variation of manometric head, power and efficiency with respect to discharge gives the operating characteristics of the pump. above figure shows operating characteristic curves of a pump. > > 2. This input power curve for pumps shall not pass through the origin. It will be slightly away from the origin on the y-axis, as even at zero discharge some power is needed to overcome mechanical losses. > > 3. The head curve will have minimum value of head when discharge is zero. > > 4. The output power curve will start from origin as at Q = 0, output power (ρQgH) will be zero. > > 5. The efficiency curve will start from origin as at Q = 0, η = 0. > $(∵ \η = {\Output}/{\Input})$ </div>

Friday 26 September 2014

Hashing in MySQL

Password Hashing in MySQL

MySQL lists user accounts in the user table of the mysql database. Each MySQL account can be assigned a password, although the user table does not store the cleartext version of the password, but a hash value computed from it.

MySQL uses passwords in two phases of client/server communication:

When a client attempts to connect to the server, there is an initial authentication step in which the client must present a password that has a hash value matching the hash value stored in the user table for the account the client wants to use.

After the client connects, it can (if it has sufficient privileges) set or change the password hash for accounts listed in the user table. The client can do this by using the PASSWORD() function to generate a password hash, or by using a password-generating statement (CREATE USER, GRANT, or SET PASSWORD).

In other words, the server checks hash values during authentication when a client first attempts to connect. The server generates hash values if a connected client invokes the PASSWORD() function or uses a password-generating statement to set or change a password.

Password hashing methods in MySQL have the history described following. These changes are illustrated by changes in the result from the PASSWORD() function that computes password hash values and in the structure of theuser table where passwords are stored.

Example 

Trigger

Introduction to SQL Trigger


Summary: in this tutorial, we will  give you a brief overview of SQL trigger, its advantages and disadvantages.

A SQL trigger is a set of  SQL statements stored in the database catalog. A SQL trigger is executed or fired whenever an event associated with a table occurs e.g.,  insert, update or delete.

A SQL trigger is a special type of stored procedure. It is special because it is not called directly like a stored procedure. The main difference between a trigger and a stored procedure is that a trigger is called automatically when a data modification event is made against a table whereas a stored procedure must be called explicitly.

It is important to understand SQL trigger’s advantages and disadvantages so that you can use it appropriately. In the following sections, we will discuss about the advantages and disadvantages of using SQL triggers.

Advantages of using SQL triggers

SQL triggers provide an alternative way to check the integrity of data.
SQL triggers can catch errors in business logic in the database layer.
SQL triggers provide an alternative way to run scheduled tasks. By using SQL triggers, you don’t have to wait to run the scheduled tasks because the triggers are invoked  automatically before or after a change  is made to the data in tables.
SQL triggers are very useful to audit the changes of data in tables.
Disadvantages of using SQL triggers

SQL triggers only can provide an extended validation and they cannot replace all the validations. Some simple validations have to be done in the application layer. For example, you can validate user’s inputs in the client side by using JavaScript or in the server side using server side scripting languages such as JSP, PHP, ASP.NET, Perl, etc.
SQL triggers are invoked and executed invisibly from client-applications therefore it is difficult to figure out what happen in the database layer.
SQL triggers may increase the overhead of the database server.

CREATE TRIGGER Syntax


CREATE
    [DEFINER = { user | CURRENT_USER }]
    TRIGGER trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW trigger_stmt

DROP TRIGGER Syntax

DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name

Example 

Thursday 25 September 2014

Program to generate 3D Object using Polygon Surfaces and then perform 3D transformation.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>         
void trans();
//void axis();
void scale();
void rotate();
int maxx,maxy,midx,midy;
/*void axis()
{
//          getch();
  //        cleardevice();
            line(midx,0,midx,maxy);
            line(0,midy,maxx,midy);
}*/
void main()
{
            int ch;
            int gd=DETECT,gm;
            detectgraph(&gd,&gm);
            initgraph(&gd,&gm,"e:\\tc\\bgi");
            printf("\n 1.Translation \n2.Scaling\n 3.Rotation \n 4.exit");
            printf("enter your choice");
            scanf("%d",&ch);
            do
            {
                        switch(ch)
                        {
                                    case 1 :             trans();
                                                            getch();
                                                      //    closegraph();
                                                            break;

                                    case 2 :             scale();
                                                            getch();
                                                      //    closegraph();
                                                            break;

                                    case 3 :             rotate();
                                                            getch();
                                                    //      closegraph();
                                                            break;

                                    case 4 :        break;
                        }
                        printf("enter your choice");
                        scanf("%d",&ch);
            } while(ch<4);
}
void trans()
{
            int x,y,z,o,x1,x2,y1,y2;
            maxx=getmaxx();
            maxy=getmaxy();
            midx=maxx/2;
            midy=maxy/2;
            //axis();
            bar3d(midx+50,midy-100,midx+60,midy-90,10,1);
            printf("Enter translation factor");
            scanf("%d%d",&x,&y);
            printf("After translation:");
            bar3d(midx+x+50,midy-(y+100),midx+x+60,midy-(y+90),10,1);
}
void scale()
{
            int x,y,z,o,x1,x2,y1,y2;
            maxx=getmaxx();
            maxy=getmaxy();
            midx=maxx/2;
            midy=maxy/2;
            //axis();
            bar3d(midx+50,midy-100,midx+60,midy-90,5,1);
            printf("before translation\n");
            printf("Enter scaling factors\n");
            scanf("%d %d %d", &x,&y,&z);
            printf("After scaling\n");
            bar3d(midx+(x*50),midy-(y*100),midx+(x*60),midy-(y*90),5*z,1);
}
void rotate()
{
            int x,y,z,o,x1,x2,y1,y2;
            maxx=getmaxx();
            maxy=getmaxy();
            midx=maxx/2;
            midy=maxy/2;
            //axis();
            bar3d(midx+50,midy-100,midx+60,midy-90,5,1);
            printf("Enter rotating angle");
            scanf("%d",&o);
            x1=50*cos(o*3.14/180)-100*sin(o*3.14/180);
            y1=50*sin(o*3.14/180)+100*cos(o*3.14/180);
            x2=60*cos(o*3.14/180)-90*sin(o*3.14/180);
            y2=60*sin(o*3.14/180)+90*cos(o*3.14/180);
   //       axis();
    //      printf("After rotation about z axis");
    //      bar3d(midx+x1,midy-y1,midx+x2,midy-y2,5,1);
            //axis();
            printf("After rotation  about x axis");
            bar3d(midx+50,midy-x1,midx+60,midy-x2,5,1);
            //axis();
            printf("After rotation about yaxis");
            bar3d(midx+x1,midy-100,midx+x2,midy-90,5,1);

}