Sunday, 6 January 2013

PROGRAM FOR PUSH POP IN C


#include<conio.h>
#include<stdio.h>
int conv(char ch);
void push(int);
void pop(int);
int stack[30],top=-1;
void main()
{
int i,j,n;
char str[30],c;
clrscr();
printf("enter string as postfix:");
scanf("%s",&str);
for(i=0;str[i]!='\0';i++)
{
printf("%c",str[i]);
if(str[i]!=',')
{
c=str[i];
n=conv(c);
if(n<0)
pop(n);
else
{
push(n);
}
}
}
printf("result= %d",stack[0]);
getch();
}
int conv(char ch)
{
int i,num=0;
switch(ch)
{
case '0':num=0;break;
case '1':num=1;break;
case '2':num=2;break;
case '3':num=3;break;
case '4':num=4;break;
case '5':num=5;break;
case '6':num=6;break;
case '7':num=7;break;
case '8':num=8;break;
case '9':num=9;break;
case '+':num=-1;break;
case '-':num=-2;break;
case '*':num=-3;break;
case '/':num=-4;break;
case '%':num=-5;break;
}
return num;
}
void push(int num)
{
stack[++top]=num;
}
void pop(int ch)
{
int op1,op2,res;
op1=stack[top--];
op2=stack[top--];
switch(ch)
{
case -1:res=op2+op1;break;
case -2:res=op2-op1;break;
case -3:res=op2*op1;break;
case -4:res=op2/op1;break;
case -5:res=op2%op1;break;
}
push(res);
}

PROGRAM FOR STRING SORTING IN JAVA


import java.io.*;

class StringSort

{

        public static void main ( String args [] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print ( "\n\n\nEnter no. of strings  :  " );

                int n = Integer.parseInt ( br.readLine () );

                String s[] = new String[n];

                System.out.println ();

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print ( "\n\nString " + (i+1) + "  :  " );

                        s[i] = br.readLine();

                }

                for ( int i=0 ; i<n-1 ; i++ )

                {

                        for ( int j=0 ; j<n-1-i ; j++ )

                        {

                                if ( s[j].compareTo ( s[j+1] ) > 0 )

                                {

                                        String tmp = s[j];

                                        s[j] = s[j+1];

                                        s[j+1] = tmp;

                                }

                        }

                }

                System.out.println ( "\n\n\nAfter sorting - \n\n" );

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print ( "\nString " + (i+1) + "  :  " );

                        System.out.println ( s[i] + "\n" );

                }

                System.out.println ();

        }

}

PROGRAM FOR CONCATENATE OF STRING IN JAVA


import java.io.*;

class Concate

{

        public static void main ( String args [] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter 1st String  :   ");

                String s1 = new String ( br.readLine() );

                System.out.print("\n\nEnter 2nd String  :   ");

                String s2 = new String ( br.readLine() );

                StringBuffer sb = new StringBuffer( concatenate ( s1 , s2 ) );

                System.out.println("\n\nStringBuffer      :   " + sb + "\n" );

        }

        public static String concatenate ( String s1 , String s2 )

        {

                return ( s1 + ' ' + s2 );

        }

}

PROGRAM FOR LEAP YEAR IN JAVA


class A

{

        int yr;

        A ( int yr )

        {

                this.yr = yr;

        }

        int IsLeap ()

        {

                if ( yr%400 == 0 )

                        return (0);

                else if ( yr%4 == 0 )

                        return (1);

                else

                        return (2);

        }
       
}

class Leap

{

        public static void main ( String args[] )

        {

                int y;

                y = Integer.parseInt ( args[0] );

                A a = new A ( y );

                int r = a.IsLeap();

                if ( r==0 )

                        System.out.println("\n\n" + y + " is a Century Leap Year\n");

                else if ( r==1 )

                        System.out.println("\n\n" + y + " is a Leap Year\n");

                else

                        System.out.println("\n\n" + y + " is not a Leap Year\n");

        }

}

PROGRAM FOR PRIME NUMBER IN JAVA


class A

{

        int IsPrime ( int n )

        {

                for ( int i=2 ; i<=n/2 ; i++ )

                {

                        if ( n%i == 0 )

                                return (1);

                }

                return (0);

        }

}

class Prime

{

        public static void main ( String args[] )

        {

                int m = Integer.parseInt ( args[0] );

                A a = new A();

                int r = a.IsPrime ( m );

                if ( r==0 )

                        System.out.println("\n\n" + m + " is a Prime no.\n");

                else

                        System.out.println("\n\n" + m + " is not a Prime no.\n");

        }

}

PROGRAM TO DISPALY DIGITAL CLOCK IN C


#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void refresh(int x, int y)
{
setfillstyle(SOLID_FILL,BLACK);
bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
}

void LCD(int x, int y, int n)
{
refresh(x,y);
setfillstyle(SOLID_FILL,10);
switch(n)
{
case 0: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 1: bar(39+x,7+y,44+x,57+y);       //c
bar(39+x,66+y,44+x,116+y);     //f
break;
case 2: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
//bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 3: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 4: //bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
//bar(7+x,118+y,37+x,123+y);     //g
break;
case 5: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
//bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 6: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
//bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 7: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
//bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
//bar(7+x,118+y,37+x,123+y);     //g
break;
case 8: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 9: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
}
}
void blink(int color)
{
setcolor(color);
setfillstyle(SOLID_FILL, color);
circle(320,280,4);
circle(320,320,4);
floodfill(320,280,color);
floodfill(320,320,color);

}
void clock(int t1, int t2, int t3, int t4)
{
int i=0;
while(1)
{
if(i==60)
{
  i=0;
  t4++;
}
LCD(200,240,t1);
LCD(250,240,t2);
LCD(350,240,t3);
LCD(400,240,t4);
blink(BLACK);
delay(700);
blink(10);
delay(200);
i++;
if(t1>=2 && t2>=3 && t3>=5 && t4>=9)
  t1=t2=t3=t4=0;
if(t4==10)
{
  t4=0;
  t3++;
  if(t3==5)
  {
    t3=0;
    if(t1!=2 && t2!=3)
    {
      t2++;
      if(t2 == 10)
      {
t2=0;
t1++;
      }
    }
  }
}
}
}
void main()
{
int gm, gd = DETECT,time,t1,t2,t3,t4;
initgraph(&gd, &gm, "..//bgi");
cleardevice();
printf("Enter Time: ");
scanf("%d",&time);
t4=time%10;
time/=10;
t3=time%10;
time/=10;
t2=time%10;
t1=time/10;
//printf("%d\t%d\t%d\t%d",t1,t2,t3,t4);
clock(t1,t2,t3,t4);
getch();
closegraph();
}

TUTORIAL FOR SQL(VIDEO)







































PROGRAM TO PRINT PATTERN IN C


/*
55555
4444
333
22
1
12
123
1234
12345
*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
for(i=2;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN IN C


/*
*****
****
***
**
*
1
12
123
1234
12345
*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTRN IN C


/*
1
12
123
1234
12345
1234
123
12
1
*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
for(i=4;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN IN C


/*
12345
1234
123
12
1
*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN IN C


/*
1
12
123
1234
12345
*/

#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN IN C


/*
55555
4444
333
22
1
*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN IN C


/*
*****
****
***
**
*
*/

#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

PROGRAM TO PRINT PATTERN PATTERN IN C


/*
1
22
333
4444
55555 */




#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

PROGRAM FOR MULTIPLICATION OF TWO MATRIX IN JAVA


import java.io.*;

class Matrix

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.println("\n\nEnter rows and columns for 1st Matrix -\n\n");

                System.out.print("Rows     :  ");

                int r1 = Integer.parseInt( br.readLine() );

                System.out.print("\nColumns  :  ");

                int c1 = Integer.parseInt( br.readLine() );

                System.out.println("\n\nEnter rows and columns for 2nd Matrix -\n\n");

                System.out.print("Rows     :  ");

                int r2 = Integer.parseInt( br.readLine() );

                System.out.print("\nColumns  :  ");

                int c2 = Integer.parseInt( br.readLine() );

                int m1[][] = new int[r1][c1];

                int m2[][] = new int[r2][c2];

                int m[][] = new int[r1][c2];

                if ( r1 != c2 )

                {

                        System.out.println("\n\nMultiplication not possible...\n");

                        System.out.println("\nRows of matrix 1 should be equal to Columns of matrix 2 !\n");

                }

                else

                {

                        System.out.println("\n\nMultiplication possible...");

                        System.out.println("\n\nEnter values for Matrix 1 -\n");

                        for ( int i=0 ; i<r1 ; i++ )

                        {

                                for ( int j=0 ; j<c1 ; j++ )

                                {

                                        System.out.print("\nEnter element [" + i + "][" + j + "] : ");

                                        m1[i][j] = Integer.parseInt( br.readLine() );

                                }

                        }

                        System.out.println("\n\nEnter values for Matrix 2 -\n");
       
                        for ( int i=0 ; i<r2 ; i++ )

                        {

                                for ( int j=0 ; j<c2 ; j++ )

                                {

                                        System.out.print("\nEnter element [" + i + "][" + j + "] : ");

                                        m2[i][j] = Integer.parseInt( br.readLine() );

                                }

                        }

                        for ( int i=0 ; i<r1 ; i++ )

                        {

                                for ( int j=0 ; j<c2 ; j++ )

                                {

                                        m[i][j] = 0;

                                        for ( int k=0 ; k<3 ; k++ )

                                                m[i][j] = m[i][j] + m1[i][k] * m2[k][j];

                                }

                        }

                        System.out.println("\n\nMultiplication -\n\n");

                        for ( int i=0 ; i<r1 ; i++ )

                        {

                                for ( int j=0 ; j<c2 ; j++ )

                                        System.out.print(m[i][j] + "  ");

                                System.out.println("\n");

                        }

                }

        }

}

PROGRAM FOR PRIME NUMBER IN JAVA


class A

{

        int IsPrime ( int n )

        {

                for ( int i=2 ; i<=n/2 ; i++ )

                {

                        if ( n%i == 0 )

                                return (1);

                }

                return (0);

        }

}

class Prime

{

        public static void main ( String args[] )

        {

                int m = Integer.parseInt ( args[0] );

                A a = new A();

                int r = a.IsPrime ( m );

                if ( r==0 )

                        System.out.println("\n\n" + m + " is a Prime no.\n");

                else

                        System.out.println("\n\n" + m + " is not a Prime no.\n");

        }

}

PROGRAM TO PRINT PATTERN IN JAVA


import java.io.*;

class A

{

        void draw ( int n )

        {

                System.out.println("\n");

                for ( int i=0,k=0 ; i<n ; i++ )

                {

                        for ( int j=0 ; j<=i ; j++,k++ )

                                System.out.print( k + "    " );

                        System.out.println("\n");

                }

        }

}

class Pattern3

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in) );

                System.out.print("\n\nEnter size : ");

                int m = Integer.parseInt ( br.readLine() );

                A a = new A();

                a.draw ( m );

        }

}

PROGRAM FOR INSERTION SORT IN JAVA


import java.io.*;

class Insertion1

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter size of array : ");

                int n = Integer.parseInt ( br.readLine() );

                int a[] = new int[n];

                System.out.println("\n\nEnter array elements -\n\n");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print("a[" + i + "] = ");

                        a[i] = Integer.parseInt ( br.readLine() );

                        System.out.println();

                }

                for ( int j=0 ; j<n ; j++ )

                {

                        int key = a[j];

                        int i = j - 1;

                        while ( i >= 0 && a[i] > key )

                        {

                                a[i+1] = a[i];

                                i--;

                        }

                        a[i+1] = key;

                }

                System.out.print("\nSorted Array  :  ");

                for ( int i=0 ; i<n ; i++ )

                        System.out.print( a[i] + "   " );

                System.out.println("\n");

        }

}

PROGRAM FOR FIBONACCI SERIES IN JAVA


class A

{

        int a,b,c;

        A ()

        {

                a = 1;

                b = 0;

        }

        void create ( int n )

        {

                for ( int i=0 ; i<n ; i++ )

                {

                        c = a + b;

                        System.out.print(b + "   ");

                        a = b;

                        b = c;

                }

        }

}

class Fibonacci

{

        public static void main ( String args[] )

        {

                int m = Integer.parseInt ( args[0] );

                A a = new A();

                System.out.println("\n\nFibonacci Series - \n\n");

                a.create( m );

                System.out.println("\n");

        }

}

PROGRAM FOR QUICK SORT IN JAVA


import java.io.*;

class Quick

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter size of Array : ");

                int n = Integer.parseInt ( br.readLine () );

                int a[] = new int[n];

                System.out.println("\n\nEnter array elements -\n ");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print("\na[" + i + "] = ");

                        a[i] = Integer.parseInt( br.readLine() );

                }

                sort ( a , 0 , n-1 );

                System.out.println("\n\nSorted Array -\n");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print("\na[" + i + "] = ");

                        System.out.println(a[i]);

                }

                System.out.println();

        }

        public static void sort ( int a[] , int l , int h )

        {

                int low,high,key,tmp;

                low = l;

                high = h;

                key = a[ ( low + high ) / 2 ];

                do

                {

                        while ( key > a[low] )

                        {

                                low++;

                        }

                        while ( key < a[high] )

                        {

                                high--;

                        }

                        if ( low <= high )

                        {

                                tmp = a[low];

                                a[low++] = a[high];

                                a[high--] = tmp;

                        }

                } while ( low <= high );

                if ( l < high )

                        sort ( a , l , high );

                if ( low < h )

                        sort ( a, low , h );

        }

}

PROGRAM FOR SELECTION SORT IN JAVA


import java.io.*;

class Selection

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter size of array : ");

                int n = Integer.parseInt ( br.readLine() );

                int a[] = new int[n];

                System.out.println("\n\nEnter array elements -\n");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print("\na[" + i + "] = ");         

                        a[i] = Integer.parseInt ( br.readLine() );

                }

                for ( int i=0 ; i<n-1 ; i++ )

                {

                        int ind = i;

                        int min = a[i];

                        for ( int j=i ; j<n ; j++ )

                        {

                                if ( min > a[j] )

                                {

                                        ind = j;

                                        min = a[j];

                                }

                        }

                        a[ind] = a[i];

                        a[i] = min;

                }

                System.out.print("\n\nSorted array  :  ");

                for ( int i=0 ; i<n ; i++ )

                        System.out.print(a[i] + "  ");

                System.out.println("\n");

        }

}

PROGRAM FOR BUBBLE SORT IN JAVA


import java.io.*;

class Bubble

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter size of array  :  ");

                int n = Integer.parseInt ( br.readLine() );

                int a[] = new int[n];

                System.out.println("\n\nEnter array elements : \n");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print("\na[" + i + "] = ");

                        a[i] = Integer.parseInt ( br.readLine() );

                }

                for ( int i=0 ; i<n-1 ; i++ )

                {

                        for ( int j=0 ; j<n-1-i ; j++ )

                        {

                                if ( a[j] > a[j+1] )

                                {

                                        int tmp = a[j];

                                        a[j] = a[j+1];

                                        a[j+1] = tmp;

                                }

                        }

                }

                System.out.print("\n\nSorted Array  :  ");

                for ( int i=0 ; i<n ; i++ )

                        System.out.print(a[i] + "   ");

                System.out.println("\n");

        }

}

PROGRAM TO PRINT STUDENT MARKSHEET IN JAVA


import java.io.*;

class Student

{

        public static void main ( String args[] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter no. of students : ");

                int n = Integer.parseInt ( br.readLine() );

                String name[] = new String[n];

                String div[] = new String[n];

                int sub[][] = new int[n][6];

                int total[] = new int [n];

                float per[] = new float[n];

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.println("\n\nEnter details of Student " + (i+1) + " -\n");

                        System.out.print("\nEnter name : ");

                        name[i] = br.readLine();

                        System.out.println("\n\nEnter marks in 6 subjects -\n");

                        System.out.print("\nSE  =  "); 

                        sub[i][0] = Integer.parseInt ( br.readLine() );

                        System.out.print("\nCA  =  ");

                        sub[i][1] = Integer.parseInt ( br.readLine() );
                                                   
                        System.out.print("\nDMS =  ");

                        sub[i][2] = Integer.parseInt ( br.readLine() );

                        System.out.print("\nCG  =  ");

                        sub[i][3] = Integer.parseInt ( br.readLine() );

                        System.out.print("\nTF  =  ");

                        sub[i][4] = Integer.parseInt ( br.readLine() );

                        System.out.print("\nITC =  ");

                        sub[i][5] = Integer.parseInt ( br.readLine() );

                        for ( int j=0 ; j<6 ; j++ )

                                total[i] += sub[i][j];

                        per[i] = (float)total[i]/6;

                        if ( per[i] >= 70 && per[i] < 100 )

                                div[i] = "Honours";

                        else if ( per[i] >= 60 && per[i] < 70 )

                                div[i] = "1st";

                        else if ( per[i] >= 45 && per[i] < 60 )

                                div[i] = "2nd";

                        else if ( per[i] >= 33 && per[i] < 45 )

                                div[i] = "3rd";
                        else

                                div[i] = "Fail";

                }

                System.out.println("\n\n\nStudent Record -\n");

                System.out.print("\n\nName\t");

                System.out.print("SE\t");

                System.out.print("CA\t");

                System.out.print("DMS\t");

                System.out.print("CG\t");

                System.out.print("TF\t");

                System.out.print("ITC\t");

                System.out.print("Total\t");

                System.out.print("%\t");

                System.out.println("Div\n\n");

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print(name[i] + "\t");

                        System.out.print(sub[i][0] + "\t");

                        System.out.print(sub[i][1] + "\t");

                        System.out.print(sub[i][2] + "\t");                        

                        System.out.print(sub[i][3] + "\t");                        

                        System.out.print(sub[i][4] + "\t");

                        System.out.print(sub[i][5] + "\t");

                        System.out.print(total[i] + "\t");

                        System.out.print(per[i] + "\t");

                        System.out.print(div[i] + "\t");

                        System.out.println("\n");

                }

        }

}

PROGRAM TO PRINT EMPLOYEE DETAILS


#include<conio.h>
#include<stdio.h>
#include<string.h>
struct employee
{
char name[20];
char address[30];
int telno;
}job[5],job1[5];
void main()
{
FILE *ptr;
int i,j,n,f;
struct employee tobj;
ptr=fopen("a.txt","w");
clrscr();
printf("enter no of ercords to insert:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter name:");
fprintf(ptr,"\n%s",job[i].name);
scanf("%s",&job[i].name);
printf("enter address:");
fprintf(ptr,"\n%s",job[i].address);
scanf("%s",&job[i].address);
printf("enter telephone no:");
fprintf(ptr,"\n%d",job[i].telno);
scanf("%d",&job[i].telno);
}
fclose(ptr);
ptr=fopen("a.txt","r");
for(i=0;i<n;i++)
{
fscanf(ptr,"\n%s",&job1[i].name);
fscanf(ptr,"\n%s",&job1[i].address);
fscanf(ptr,"\n%d",&job1[i].telno);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
f=strcmpi(job1[j].name,job1[j+1].name);
if(f>0)
{
tobj=job1[j];
job1[j]=job1[j+1];
job1[j+1]=tobj;
}
else
{
f=strcmpi(job1[j].address,job1[j+1].address);
if(f>0)
{
tobj=job1[j];
job1[j]=job1[j+1];
job1[j+1]=tobj;
}
}
}
}
fclose(ptr);
ptr=fopen("d.txt","w");
for(i=0;i<n;i++)
{
printf("\n\nname %s",job1[i].name);
fprintf(ptr,"\nname:%s",job1[i].name);
printf("\naddress %s",job1[i].address);
fprintf(ptr,"\naddress %s",job1[i].address);
printf("\ntelno %d",job1[i].telno);
fprintf(ptr,"\ntelno %d",job1[i].telno);
}
fclose(ptr);
getch();
}