Wednesday, 20 March 2013

/*A Program by Raghav Raj to create a linked list to store the details of Students,Also to delete any record of student with the specified roll no from the list*/

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<string.h>
struct student
{
    int roll;
    char name[10];
    char add[10];
    struct student *next;
};
struct student *start = NULL;
void create_Record(int,char*,char*);
void display();
void delete_Record(int);
void main()
{
  int n,i,r;
  char nm[10],ad[10];

  printf("How Many Student's Record You want to create  :");
  scanf("%d",&n);
  for(i=0; i<n; i++)
  {
     clrscr();
      printf("\n\tEnter Record %d : ",i+1);
      printf("\nEnter Roll :");
      scanf("%d",&r);
      printf("\nEnter Name :");
      scanf("%s",nm);
      printf("\nEnter Address :");
      scanf("%s",ad);
      create_Record(r,nm,ad);
  }
  clrscr();
  printf("\n\t\t****Student Records********\n\n");
  display();
  printf("\nEnter Roll No of Student To delete The record from List :");
  scanf("%d",&r);
  delete_Record(r);
  printf("After deletion of Record Of a Student List Is: ");
  display();
  getch();
}

  void create_Record(int rl,char *nm,char *ad)
  {
      struct student *q,*tmp;
      tmp = (struct student*)malloc(sizeof(struct student));
      tmp->roll = rl;
      strcpy(tmp->name,nm);
      strcpy(tmp->add,ad);
      tmp->next = NULL;

      if(start == NULL)
          start = tmp;
      else
      {
         q = start;
         while(q->next != NULL)
              q = q->next;
         q->next = tmp;
      }
  }
  void display()
  {
      struct student *tmp;
      if(start == NULL)
      {
            printf("\nList is Empty : ");
            return;
      }
      tmp = start;
      printf("\nRoll\tName\tAddress\n\n");
      while(tmp != NULL)
      {
          printf("%d\t%s\t%s\n",tmp->roll,tmp->name,tmp->add);
          tmp = tmp->next;
      }
      printf("\n");
  }
  void delete_Record(int rl)
  {
      struct student *tmp,*q;
      if(start->roll == rl)
      {
            tmp = start;
            start = start->next;
            free(tmp);
            return;
      }
      q = start;
      while(q->next->next != NULL)
      {
            if(q->next->roll == rl)
            {
                tmp = q->next;
                q->next = tmp->next;
                free(tmp);
                return;
            }
            q = q->next;
      }//End of While
      if(q->next->roll == rl)
      {
         tmp = q->next;
         free(tmp);
         q->next = NULL;
         return;
      }
      printf("Roll No %d Not Found in the List\n\n",rl);
  }

Saturday, 16 March 2013

/*A program designed by Raghav Raj in Java To create a Student Database */
import java.util.Scanner;
class Student
{
   String name[];
   int roll[];
   String add[];
   String course[];
   long fee_deposit[],dues[];
   long total = 100000;
   void Input()
   {
       Scanner sc = new Scanner(System.in);
       System.out.print("How many Records you want to store in Student Database :");
       int n = sc.nextInt();
       //array dynamic Memory Allocation
       name = new String[n];
       roll = new int[n];
       add  = new String[n];
       course = new String[n];
       fee_deposit = new long[n];
       System.out.println(">>>>>>>>>>>>>>Enter Details of "+n+" Student<<<<<<<<<<<<<< ");
       for(int i=0; i<n; i++)
       {
           System.out.println("Now Enter Detatils of Student "+(i+1)+" : ");
           System.out.print("Enter Name : ");
           name[i] =sc.next();
           System.out.print("\nEnter Roll : ");
           roll[i] = sc.nextInt();
           System.out.print("\nEnter Address : ");
           add[i] = sc.next();
           System.out.print("\nEnter Course : ");
           course[i] = sc.next();
           System.out.print("\nEnter Fee for Deposit : ");
           fee_deposit[i] = sc.nextLong();
        }
   }
   void Output()
   {
       System.out.println("_________________________________________________");
       System.out.println("*********-->> Students Records <<--*********\n");
       System.out.println("_________________________________________________\n");
       System.out.println("_____________________________________________________________________________________");
       System.out.println("Roll\tName\t\tAddress\t\tCourse\tTotal\tFee Deposit\tDues");
       System.out.println("_____________________________________________________________________________________\n");
       for(int i=0; i<roll.length; i++)
       {
           System.out.print(roll[i]+"\t");
           System.out.print(name[i]+"\t\t");
           System.out.print(add[i]+"\t\t");
           System.out.print(course[i]+"\t");
           System.out.print(total+"\t");
           System.out.print(fee_deposit[i]+"\t\t");
           System.out.print(dues[i]);
           System.out.println();
       }
   }
   void Dues()
   {
       dues = new long[roll.length];
       for(int i=0; i<roll.length; i++)
       {
           dues[i] = total-fee_deposit[i];
       }
   }

   void Search(int key)
   {
      
       int i;     
       for(i=0; i< roll.length; i++)
       {
           if(roll[i] == key)
           {
               System.out.println("Which Field you want to see of Roll No "+key+": " );
               System.out.print("Please Enter :");
               System.out.println(" 1. for Name ");
               System.out.println(" 2. for Address ");
               System.out.println(" 3. for Course ");
               System.out.println(" 4. for Fee Deposit ");
               System.out.println(" 5. for Dues ");
               System.out.println(" 6. for All Fields ");
               Scanner sc = new Scanner(System.in);
               int choice = sc.nextInt();
               switch(choice)
               {
                   case 1 :
                       System.out.print("Name of Roll No. "+key+" is : "+name[i]);
                       break;
                   case 2 :
                       System.out.print("Address of Roll No. "+key+" is :"+add[i]);
                       break;
                   case 3 :
                       System.out.print("Course of Roll No. "+key+" is :"+course[i]);
                       break;
                   case 4 :
                       System.out.print("Fee Deposited by Roll No. "+key+" is : "+fee_deposit[i]);
                       break;
                   case 5 :
                       System.out.print("Dues Of Roll No. "+key+" is : "+dues[i]);
                       break;
                   case 6 :
                       System.out.println("Roll\tName\t\tAddress\t\tCourse\tTotal\tFee Deposit\tDues \n");
                       System.out.print(roll[i]+"\t");
                       System.out.print(name[i]+"\t\t");
                       System.out.print(add[i]+"\t\t");
                       System.out.print(course[i]+"\t");
                       System.out.print(total+"\t");
                       System.out.print(fee_deposit[i]+"\t\t");
                       System.out.print(dues[i]);
                       break;
                       
                   default :
                       System.out.println("This Record Does Not Exists in this Database ");
                       System.out.print("*****Thanks*****");
                       break;
               }
               break;
           }
           else
               continue;
       }
      
       if( i == roll.length)
          System.out.println("Record Does Not Exists ");
    }
}
              
              
          
class StudentDatabase
{
      public static void main(String args[]) 
      {
          Student s = new Student();
          s.Input();
          s.Dues();
          s.Output();
          //to see a particular record in Database
          Scanner sc = new Scanner(System.in);
          System.out.println("Enter Roll No As Primary Key to See A particular Record From DataBase :");
          int rollNo = sc.nextInt();
          s.Search(rollNo);
         
         
      }
}
          
  
          
          
      

Friday, 15 March 2013

http://adf.ly/Kw8T0


Turbo C++ V4.5 for Windows

//A Java Program For Multiplication of two complex numbers
class Complex
{
   double real;
   double imag;
  
   Complex()
   {
       real = 4.0;
       imag = 5.0;
   }
   Complex(double r, double i)
   {
       real = r;
       imag = i;
   }
   void show()
   {
       System.out.println("Complex Number is ("+real+" + i "+imag+")");
   }
  
   Complex multiply(Complex x, Complex y)
   {
       Complex Mul = new Complex();
       Mul.real = x.real*y.real - x.imag*y.imag;
       Mul.imag = x.real*y.imag + x.imag*y.real;
       return Mul;
   }
}
class Operation
{
  public static void main(String args[])
  {
      Complex a = new Complex();
      Complex b = new Complex(7.0,8.2);
      Complex c = new Complex();
      a.show();
      b.show();
      c = c.multiply(a,b);
      c.show();
  }
}
 

Saturday, 9 March 2013



//A Program Desined by Raghav Raj to Solve the Tower Of Hanoi Problem Using Recursive function
#include<stdio.h>
#include<conio.h>
int toh(int,char,char,char);
void main()
{
  char source='S',temp='T',dest='D';
  int nDisk;
  printf("Enter the number of disk: ");
  scanf("%d",&nDisk);
  printf("\nSequence is : ");
  toh(nDisk,source,temp,dest);
  getch();
}
int toh(int ndisk,char source,char temp,char dest)
{
  if(ndisk>0)
  {
    toh(ndisk-1,source,dest,temp);
    printf("\nMove Disk %d %c-->%c\n",ndisk,source,dest);
    toh(ndisk-1,temp,source,dest);
  }
}