Skip to main content

Posts

Showing posts from May, 2018

NESTED if else in C

  NESTED if else syntax with disadvantage in C   if ….else Suppose if you want to execute a part of program if a particular condition is true as well as condition is false then we can enclose these statement within if ..else statement like. Syntax             If(condition)                 {                     Statement……                 }                   else         {                 statement..       }     nested if …else Suppose if you want to execute a part of program in which a particular condition is depend on the...

Draw Line in Paint: JAVA

           Draw Line in Paint:java swing import java.awt.*; import java.awt.event.*; class Cdraw implements MouseMotionListener {  Frame f;  Graphics g;  int i,px,py;  public Cdraw()  {   f=new Frame();  f.setSize(900,900);   f.addMouseMotionListener(this);   f.setVisible(true);   g=f.getGraphics();   }  public void mouseMoved(MouseEvent e)  { i=0;  }  public void mouseDragged(MouseEvent e1)  {       int x=e1.getX();       int y=e1.getY();         if( i==0)       {            px=x;            py=y;       }         g.setColor(Color.red);   g.drawLine(px,py,x,y); ...

Drawing text in java

              Drawing text swing awt,in java   Drawing is done with the drawString() method. We specify the string we want to draw and the position of the text on the window area.   import java.awt.Font; package PRACTICEPROGRAM; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class DrawPanel extends JPanel {     @Override     public void paintComponent(Graphics g) {         super.paintComponent(g);         Graphics2D g2d = (Graphics2D) g;         RenderingHints rh = new RenderingHints(                 RenderingHints.KEY_ANTIALIASING,   ...

Prime no using IF else in c

                         Prime no using IF else   if ….else Suppose if you want to execute a part of program if a particular condition is true as well as condition is false then we can enclose these statement within if ..else statement like. Syntax                                                                      If(condition)                            ...

The Decision Control Structure Simple "IF" comdition in C

                   The Decision Control Structure       Simple if Suppose if you want to execute a part of program if a particular condition is true we can enclose these statement within if {} statement Syntax                         If(condition)                                                 {                                   ...