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

#include<stdio.h>
#include<conio.h>
int main()
{
  int n,sum,temp,rem;
  n=100;
  sum=0;
  printf(" Armstrong Number betWeen 100 to 1000 :-");
     temp=n;
     while(n<=1000)
     {
       temp=n;
       while(temp!=0)
       {
         rem=temp%10;
         sum+=rem*rem*rem;
         temp=temp/10;
       }
       if(n==sum)
       printf(" %d ",sum);
       sum=0;
       n++;
     }
getch();
return 0;
}

/*A Program Developed By Raghav Raj To generate the Pascal's Triangle..*/
#include<stdio.h>
#include<conio.h>
long factorial(int);

main()
{
   clrscr();
   int i, n, c;

printf("Enter the number of rows you wish to see in pascal triangle : ");
   scanf("%d",&n);

   for ( i = 0 ; i < n ; i++ )
   {
      for ( c = 0 ; c <= ( n - i - 2 ) ; c++ )
printf(" ");

for( c = 0 ; c <= i ; c++ )
printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));

      printf("\n");
   }
   getch();
   return 0;
}

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
result = result*c;
   return ( result );
}

/*   The total distance travelled by vehicle in 't' seconds is given by distance = ut+1/2at2
 where 'u' and 'a' are the initial velocity (m/sec.) and acceleration (m/sec2).
 Write C program to find the distance travelled at regular intervals of time given
     the values of 'u' and 'a'. The program should provide the flexibility to the user
     to select his own time intervals and repeat the calculations for different values of 'u' and 'a'.
*/


#include <stdio.h>
#include <math.h>
#include<conio.h>




void main()
{
int tim_intrval, counter,time;
float accl, distance=0, velos;
clrscr();
printf("<===========PROGRAM FOR CALC TOTAL DISTANCE TRAVELED BY A VECHIAL===========>");
printf("\n\n\n\t\t\tNO OF TIME INTERVALS : ");
scanf("%d",&tim_intrval);


for(counter = 1; counter <= tim_intrval; counter++)
{
        printf("\n\t\t\tAT T%d TIME(sec) : ",counter);
        scanf("%d",&time);
        printf("\t\t\tVELOCITY AT %d sec (m/sec) : ",time);
        scanf("%f",&velos);
        printf("\t\t\tACCLERATION AT %d sec (m/sec^2): ",time);
        scanf("%f",&accl);
 distance = (velos*time + (accl*pow(time,2))/2);
}


printf("\n\n\n\tTOTAL DISTANCE TRAVELLED BY VEHICLE IN %d INTERVALS OF TIME : %f",tim_intrval,distance);
getch();
}
/*A C Program to print the Shapes like Diamond Of *(Asterisk )Symbol  */

               *
           *  *  *
       *  *  *  *  *
    * *  *  *  *  *  *
*  * *  *  *  *  *  *  *
    * *  *  *  *  *  *
       *  *  *  *  *
           *  *  *
               *


#include <stdio.h>
#include <conio.h>
int main()
{
  int n, c, k, space = 1;

  printf("Enter number of rows\n");
  scanf("%d", &n);

  space = n - 1;

  for (k = 1; k <= n; k++)
  {
for (c = 1; c <= space; c++)
printf(" ");

space--;

for (c = 1; c <= 2*k-1; c++)
{

if(c==1||c==2*k-1)
printf("R");
else
printf("*");
}
printf("\n");
  }

  space = 1;

  for (k = 1; k <= n - 1; k++)
  {
for (c = 1; c <= space; c++)
printf(" ");

space++;

for (c = 1 ; c <= 2*(n-k)-1; c++)
 {
 if(c==1||c==2*(n-k)-1)
printf("R");
 else
printf("*");
 }
printf("\n");
  }
  getch();
  return 0;
}
/*A program in c to multiply two matrices*/

/*A Program Developed By Raghav Raj For Multiplying Two
  Square Matrices*/
#include<stdio.h>
#include<conio.h>
#define ROW 6
#define COL 6
void display(int [][COL],int,int,int,int);
void main()
{
 int i,j,rowA,colA,rowB,colB;
 int A[ROW][COL],B[ROW][COL],sum=0;
 int k;
 printf("\nEnter row and column for Matrix A: ");
 scanf("%d%d",&rowA,&colA);
 printf("\nEnter elments for Matrix A%d X %d : ",rowA*colA);
 for(i=0;i<rowA;i++)
 {
  for(j=0;j<colA;j++)
  { //clrscr();
   printf("\nEnter element for A[%d][%d] : ",i,j);
   scanf("%d",&A[i][j]);
  }
 }
 clrscr();
 printf("Enter row and column for Matrix B : ");
 scanf("%d%d",&rowB,&colB);
 printf("\nEnter element for Matrix B %d X %d :",rowB*colB);
 for(i=0;i<rowB;i++)
 {
  for(j=0;j<colB;j++)
  { //clrscr();
    printf("\nEnter elemnet for B[%d][%d] : ",i,j);
    scanf("%d",&B[i][j]);
  }
 }clrscr();
 printf("Matrix A and B Are  :\n\t");
 display(A,rowA,colA,9,2);
 gotoxy(1,rowA);
 printf("A X B =");
 gotoxy(18,rowA);
 printf(" X ");
 gotoxy(22,2);
 display(B,rowB,colB,22,2);
 gotoxy(34,rowA);
 printf(" =");
 //Inputting done in both Matrices
 //Now calculate the multiplication of Matrices A and B
 gotoxy(1,rowA+3);
 if(colA==rowB)
 {
 printf("\nMultiplication of Matrices A and B are :\n");
 for(i=0;i<rowA;i++)
 {
   for(k=0;k<colA;k++)
   {
     for(j=0;j<rowB;j++)
     {
       sum+=A[i][j]*B[j][k];
     }
   printf("  %d\t",sum);
   sum=0;
   }
   printf("\n");
 }
 }
 else
 { clrscr();
   printf("\nMultipltion of Matrices can not be performed");
   printf("\n\nBecause,Matrix A and B Does not Exist\n\n\t\tThanks....");
 }
 getch();
 }
 void display(int matA[][ROW],int r,int c,int x,int y)
 {
   int i,j;
   for(i=0;i<r;i++)
   {
     for(j=0;j<c;j++)
     {
       printf("%d   ",matA[i][j]);
     }
     y=y+1;
     gotoxy(x,y);
   }
 }