Sunday, 14 July 2013

write a program to find the largest number between three numbers



  #include<stdio.h>


int main ()
{
    int a,b,c;
   
    printf("enter three number\n");
     scanf("%d%d%d", &a , &b , &c);
     printf("A = %d \nB =%d \nC = %d \n " , a ,b ,c );
   
     if(a>b)
     {
        if(a>b)
     
       {
       printf("a is greater\n");
       }
       else
       {
           printf("c is greater\n");
           }
           }
           else
           {
               if (b<c)
               {
                       printf("b is greater\n");
                       }
                       else
                       {
                           prentf("c is greater\n");
                           }
                           }
                           gatch();
                           return 0;
                         
                           

Wednesday, 10 July 2013

Different Components Of Awt class

//<applet code=Components width=700 height=600></applet>
import java.applet.*;
import java.awt.*;
public class Components extends Applet
{

        Label l1;
        TextField t1,t2;
        Checkbox c1,c2,c3;
        CheckboxGroup cbg;
        TextArea ta;
        List li;
        Choice c;
        Button b;
        public void init()
        {
                l1=new Label("Enter Name");
                add(l1);
                t1=new TextField(10);
                add(t1);


                c1=new Checkbox("Cricket");
                add(c1);

                cbg=new CheckboxGroup();
                c2=new Checkbox("Male",cbg,false);
                c3=new Checkbox("Female",cbg,false);
                add(c2);
                add(c3);
                ta=new TextArea(5,15);
                add(ta);
                li=new List();
                li.addItem("Sunday");
                li.addItem("Monday");
                li.addItem("Tuesday");
                li.addItem("Wednesday");
                li.addItem("Thursday");
                add(li);
                c=new Choice();
                c.addItem("Sunday");
                c.addItem("Monday");
                c.addItem("Tuesday");
                c.addItem("Wednesday");
                c.addItem("Thursday");
                add(c);
                b=new Button("Press");
                add(b);
                t2=new TextField(10);
                add(t2);
        }
}


                                                                OUTPUT


Command prompt
 
 

Applet
 

program for printing table of a given number using java

import java.io.*;
public class Table
{
        public static void main(String ap[]) throws IOException
 {
                InputStreamReader i=new InputStreamReader(System.in);
                BufferedReader br=new BufferedReader(i);
                int a;
                System.out.println("enter number");
                a=Integer.parseInt(br.readLine());
                System.out.println("table of " +a);
                for(int j=1;j<=10;j++)
                System.out.println(a*j);
        }
}

Program for sum of integers using array in java

import java.io.*;
public class Sumarray
{
        public static void main(String ap[])throws IOException
        {
                InputStreamReader i=new InputStreamReader(System.in);
                BufferedReader br=new BufferedReader(i);
                int a[]=new int [5];                // we have taken an array a of size 5
                int S=0;                                // initialized value of S at zero S is used for storing sum
                System.out.println("enter five numbers to sum");
                for(int j=0;j<5;j++)
                {
                        a[j]=Integer.parseInt(br.readLine());                // we need to do typecasting because the datatypes on the both side of the operator.
                        S=S+a[j];
                }
                System.out.println("sum="+S);
        }
}
 

Program For Sum of integers using java

import java.io.*;
public class Suminteger
{
        public static void main(String ap[]) throws IOException
        {
                InputStreamReader i=new InputStreamReader(System.in);
                BufferedReader br=new BufferedReader(i);
                int a,b,s;  // we have taken three variables,a and b for inserting values and s for storing Sum of a and that is a+b
                System.out.println("enter value of a and b");
                a=Integer.parseInt(br.readLine());
                b=Integer.parseInt(br.readLine());
                s=a+b;
                System.out.println("sum="+s);
        }
}

write a program to find the area of circle

class circle
{
          public float r;
          public void set radius()
          {
                    r=10;
          }
          public void findarea()
          {
                    float area=3.14f*r*r;
                    System.out.println("The area is="+area);
          }
}
public test class
{
          public static void main(String ap[])
          {
                    Circle c1=new Circle();
                    System.out.println("the value of r is=c1.r);
                    c1.setRadius();
                    System.out.println(The value of r is="c1.r);
                    c1.findarea();
          }
}

Monday, 8 July 2013

what are classes and objetcs?




class box

{
public:
double length;//length of box
double breadth;//breadth of box
double height;//height of box
};
object- object are the run time entities
classes
classes  -it is a user defined data types