Skip to main content

Posts

Use of else if to find largest among three in C

            Largest among three using else if   #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf(“Enter three values\n”); scanf(“%d%d%d”,&a,&b,&c); printf(“\n Largest value is “); if(a>b && a>c)    {         printf(“%d\n”,a);    } elseif(b>a && b>c) {       printf(“%d\n”,b);   }                                         else {        printf(“%d\n”,c); } getch();   }

Use else if with example total of marks and percentage & Grade in C

    Use else if with example ( total of marks and percentage & Grade ) "else if" It remove the above problem but it has own problem it check all the condition until one condition is true. So it is time consuming. Syntax:-                                              If(condition1)                                                 {                           ...

Largest of three in C and C++

             Largest of three values using IF else   Largest of three values: #include<stdio.h> #include<conio.h> void main() {                                              float a,b,c;                                              printf(“Enter three values\n”);                               ...

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); ...