Friday 19 August 2011

COMPUTER SCIENCE MCQ - Timothy Williams.pdf

Download  COMPUTER SCIENCE MCQ - Timothy Williams Book

From the below link which is more helpful for computer science students

http://www.uploadstation.com/file/UGGNFmZ




Text book of environmental studies for undergraduates courses by Erach Bharucha

download the text in word format of

Text book of environmental studies for undergraduates courses by Erach Bharucha,
   Published by – University Grants Commission, Universities Press,India.

from the below link:




Friday 12 August 2011

Basic Electronics 2







Friends,These are the test questions.I mentioned page numbers for every page.so,check it before writing.

Basic Electronics











Friends I have uploaded 2 different methods for 1st problem, i didn't check which one is right, check it once before you write.
Also i mentioned page numbers, except for 1st 2 photos (different).

Monday 8 August 2011

Product of Sparse Matrix


Write a routine to find product of two sparse matrices

void sparse::product(sparse &a,sparse &b)
{
       int sum,k,position,posi,flaga,flagb;
       k=1;
       result=new int[MAX SIZE *3];
       for(int i=0;i<*(a.sp+0*3+0);i++)
       {
      for(int j=0;j<*(b.sp+0*3+1);j++)
      {
serchina(a.sp,i,&position,&flaga);
if(flaga==TRUE)
{
   sum=0;
   while(*(a.sp+position*3+0)==i)
{
searchinb(b.sp,j,*(a.sp+position*3+1),&posi,&flagb);
     if(flagb==TRUE)
sum=sum+*(a.sp+position*3+2)**(b.sp+posi*3+2);
position=position+1;
}
if(sum!=0)
{
*(result+k*3+0)=j;
*(result+k*3+1)=j;
*(result+k*3+2)=sum;
k=k+1;
}
}
}
         }
*(result+0*3+0)=*(a.sp+0*3+0);
*(result+0*3+1)=*(b.sp+0*3+1);
*(result+0*3+2)=k-1;
}

Friday 5 August 2011

Matrix Program for Addition,Substraction,Multiplication and Transpose

#include<iostream>
#include<cstdlib>
using namespace std;
class matrices
{
        int **matrix;
        int m,n;
        public:
        void setmatrix();
        void addition();
        void subtraction();
        void multiplication();
        void transpose();
        void display();
};
void matrices::setmatrix()
{
        cout<<"Enter the size of the matrix:";
        cin>>m>>n;
        matrix=new int*[m];
        for(int i=0;i<m;i++)
                matrix[i]=new int[n];
        cout<<"Enter the elements of the matrix:";
        for(int i=0;i<m;i++)
                for(int j=0;j<n;j++)
                        cin>>matrix[i][j];
}
void matrices::display()
{

        for(int i=0;i<m;i++)
        {
                for(int j=0;j<n;j++)
                        cout<<matrix[i][j]<<"\t";
                cout<<"\n";
        }
}
void matrices::addition()
{
        matrices ob1,ob2,result;
        cout<<"\nFirst Matrix:\n";
        ob1.setmatrix();
        cout<<"\nSecond Matrix:\n";
        ob2.setmatrix();
        if(ob1.m!=ob2.m||ob1.n!=ob2.n)
                cout<<"Addition cannot be performed.";
        else
        {
                result.matrix=new int*[ob1.m];
                result.m=ob1.m;
                result.n=ob1.n;
                for(int i=0;i<ob1.m;i++)
                        result.matrix[i]=new int[ob1.n];
                for(int i=0;i<ob1.m;i++)
                        for(int j=0;j<ob1.n;j++)
                                result.matrix[i][j]=ob1.matrix[i][j]+ob2.matrix[i][j];
                cout<<"Matrices sum is:\n";
                result.display();
        }
}
void matrices::subtraction()
{
         matrices ob1,ob2,result;
        cout<<"\nFirst Matrix:\n";
        ob1.setmatrix();
        cout<<"\nSecond Matrix:\n";
        ob2.setmatrix();
        if(ob1.m!=ob2.m||ob1.n!=ob2.n)
                cout<<"Subtraction cannot be performed.";
        else
        {
                result.matrix=new int*[ob1.m];
                result.m=ob1.m;
                result.n=ob1.n;
                for(int i=0;i<ob1.m;i++)
                        result.matrix[i]=new int[ob1.n];
                for(int i=0;i<ob1.m;i++)
                        for(int j=0;j<ob1.n;j++)
                                result.matrix[i][j]=ob1.matrix[i][j]-ob2.matrix[i][j];
                cout<<"Matrices difference is:\n";
                result.display();
        }
}
void matrices::multiplication()
{
        matrices ob1,ob2,result;
        int k,sum;
        cout<<"\nFirst Matrix:\n";
        ob1.setmatrix();
        cout<<"\nSecond Matrix:\n";
        ob2.setmatrix();
        if(ob1.n!=ob2.m)
                cout<<"Multiplication cannot be performed.";
        else
        {
                result.matrix=new int*[ob1.m];
                result.m=ob1.m;
                result.n=ob2.n;
                for(int i=0;i<ob1.m;i++)
                        result.matrix[i]=new int[ob1.n];
                for(int i=0;i<ob1.m;i++)
                        {
                                for(int j=0;j<ob2.n;j++)
                                {
                                        sum=0;
                                        k=0;
                                        while(k<ob1.n)
                                        {
                                                sum=sum+ob1.matrix[i][k]*ob2.matrix[k][j];
                                                k++;
                                        }
                                        result.matrix[i][j]=sum;
                                }
                        }
                cout<<"Matrices product is:\n";
                result.display();
        }
}
void matrices::transpose()
{
        matrices ob1,ob2;
        ob1.setmatrix();
        ob2.matrix=new int*[ob1.n];
        for(int i=0;i<ob1.n;i++)
                ob2.matrix[i]=new int[ob1.m];
        for(int i=0;i<ob1.m;i++)
                for(int j=0;j<ob1.n;j++)
                        ob2.matrix[j][i]=ob1.matrix[i][j];
        ob2.m=ob1.n;
        ob2.n=ob1.m;
        cout<<"Transpose is :\n";
        ob2.display();
}
int main()
{
        matrices ob;
        int option;
        while(1)
        {
                cout<<"\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Transpose\n5.Display\n6.Exit Program";
                cout<<"\n\nEnter your option:";
                cin>>option;
                switch(option)
                {
                        case 1:
                                ob.addition();
                                break;
                        case 2:
                                ob.subtraction();
                                break;
                        case 3:
                                ob.multiplication();
                                break;
                        case 4:
                                ob.transpose();
                                break;
                        case 5:
                                ob.display();
                                break;
                        case 6:
                                exit(1);
                }
        }
}

Thursday 4 August 2011

Circular Linked List Program

#include<iostream>
using namespace std;
class cll
{
        struct std
        {
                int rno;
                char name[20];
                struct std *link;
        }*head;
        int size;
        public:
                cll()
                {
                        head=NULL;
                }
                void display();
                void insertbegin();
                void insertmiddle(int rno);
                void insertend();
                void deletebegin();
                void deletemiddle();
};
void cll::display()
{
        std *t;
        t=head;
        while(t->link!=head)
        {
                cout<<"\n name is: "<<t->name;
                cout<<"\n rno is: "<<t->rno;
                t=t->link;
        }
        cout<<"\n name is: "<<t->name;
        cout<<"\n rno is: "<<t->rno;
}
void cll::insertbegin()
{
        std *t;
        t=new std;
        cout<<"\n enter rno,name ";
        cin>>t->rno>>t->name;
        if(head==NULL)
        {
                t->link=t;
                head=t;
        }
        else
        {
                std *p=head;
                while(p->link!=head)
                        p=p->link;
                t->link=head;
                p->link=t;
                head=t;
        }
}
void cll::insertmiddle(int rno)
{
        std *t;
        t=new std;
        cout<<"\n enter rno&name ";
        cin>>t->rno>>t->name;
        if(head==NULL)
        {
                head=t;
                t->link=head;
        }
        else
        {
                std *p;
                p=head;
                while(p->rno!=rno && p->link!=head)
                        p=p->link;
                t->link=p->link;
                p->link=t;
        }
}
void cll::insertend()
{
        std *t;
        t=new std;
        cout<<"\n enter rno,name ";
        cin>>t->rno>>t->name;
        if(head==NULL)
        {
                t->link=t;
                head=t;
        }
        else
        {
                std *p=head;
                while(p->link!=head)
                        p=p->link;
                t->link=head;
                p->link=t;
        }
}
void cll::deletebegin()
{
        if(head==NULL)
        {
                cout<<"\n cll is empty ";
        }
        else
        if(head->link==head)
        {
                delete head;
                head==NULL;
        }
        else
        {
                std *p=head;
                while(p->link!=head)
                        p=p->link;
                p->link=head->link;
                std *t;
                t=head;
                head=head->link;
                delete t;
        }
}
void cll::deletemiddle()
{
        struct std *t,*p;
        p=head;
        int no;
        if(head==NULL)
        {
                cout<<"list is empty \n";
        }
        else if(head->link==head)
        {
                delete head;
                head=NULL;
        }
        else
        {
                cout<<"enter the rno you want to delete : ";
                cin>>no;
                while(p->link->rno!=no&p->link!=head)
                p=p->link;
                t=p->link;
                p->link=t->link;
                t->link=NULL;
                delete(t);
        }
}
int main()
{
        int option,rno,n=1;
        cll ob;
        while(n==1)
        {
                cout<<"\n enter your option: ";
                cout<<"\n 1) display \n 2) insertbegin \n 3) insertmiddle \n 4) insertend \n 5) deletebegin \n 6) deletemiddle \n 7) exit \n ";
                cin>>option;
                switch(option)
                {
                        case 1:
                                ob.display();
                                break;
                        case 2:
                                ob.insertbegin();
                                break;
                        case 3:
                                cout<<"\n enter the rno after which you want to insert: ";
                                cin>>rno;
                                ob.insertmiddle(rno);
                                break;
                        case 4:
                                ob.insertend();
                                break;
                        case 5:
                                ob.deletebegin();
                                break;
                        case 6:
                                ob.deletemiddle();
                                break;
                        case 7:
                                n=0;
                                break;
                }
        }
}