Friday, June 6, 2014

PASCAL TRIANGLE

/*
ITS A PASCAL TRIANGLE IMPLEMENTED IN JAVA
GENERATED OUTPUT

                        1
                     1   1
                   1  2   1
                 1  3   3    1
              1   4   6   4     1

*/


import java.io.*;
class pascal
     {
   public static void main(String args[])  throws IOException
         {
int i=0,n=0,b=1,c=2,d=2,e=0,f=2,g=3;
DataInputStream ds=new DataInputStream(System.in);
int []a=new int[50];
System.out.println("Enter count");
n=Integer.parseInt(ds.readLine());
for(i=0;i<=n;i++)
{
if(i==0||i==b||i==c)
{
a[i]=1;
System.out.print(a[i]+"\t");
}
else
{
e=i-d;
a[i]=a[e]+a[++e];
System.out.print(a[i]+"\t");
}

if(i==0)
{
System.out.println();
}
if(i==c)
{
System.out.println();
b=b+f;
f++;
c=c+g;
g++;
d++;
}
}
}
}

INTEGER PROCESSING IN JAVA 7

import java.util.Scanner;
class sum
{
public static void main(String args[])
{
int a,b,c;
Scanner in = new Scanner(System.in);
System.out.println("Enter two values");
a=in.nextInt();
b=in.nextInt();
c=a+b;
System.out.printf("The sum is %d",c);
}
}

HELLO WORLD IN JAVA 7

class hello
{
public static void main(String args[])
{
System.out.printf("%s\n%s\n","hello","kisshor");
}
}