C++ Project

0
  • on Wednesday, December 15, 2010
  • C++ Programs and Projects are available
    Dear Students we have tried to solve and post over here all possible problems from Dietel and Dietel Book.
    All suggestions will highly be appreciated.

    All C++ codes for learners

    0
  • on
  • Question # 1 Multiply two matrices

    void multiply()
    {

    int r,x,y,c;
    float a[10][10],b[10][10],d[10][10]={0};
    cout<<"enter no. of rows of matrix A = ";
    cin>>r;
    cout<<"enter no. of columns of matrix A = ";
    cin>>x;
    cout<<"enter no. of rows of matrix B =";
    cin>>y;
    while (x!=y)
    {
    cout<<"the given order is not compatible for multiplication of matrices\n";
    cout<<"enter no. of rows of matrix B =";
    cin>>y;
    }
    cout<<"enter no. of columns of matrix B = ";
    cin>>c;
    cout<<"\nenter the values of matrix A\n";
    input (a,r,x);
    cout<<"\nenter the values of matrix B\n";
    input (b,y,c);
    for (int p=0;p<r;p++)
    for (int j=0;j<c;j++)
     for (int i=0;i<x;i++)
    d[p][j]=d[p][j]+a[p][i]*b[i][j];
    cout<<"\nthe product A*B is\n\n";
    output (d,r,c);

             //* CHAP # 2     Q # 24 *//
        //* Find whether an intger is even or odd *//


    #include <iostream.h>
    void main ()
    {
     int a;
     cout <<"Enter an integer";
     cin>>a;
     cout <<endl<<endl<< endl;
     if (a%2==0)
        cout <<"The integer is even ";
     else
       cout <<"The integer is odd  ";

    }



                              //* CHAP # 2    Q # 26 *//
                 //* PRINT  THE specified patterrn according to the no of stars & lines by the user*


         #include <iostream.h >
         void main ()
         {
           int n;
           cout <<"Enter the no Of stars";
           cin>>n;
           for(int i=0 ; i<n; i++ )
            {
        if(i%2==0)
         { for(int j=0; j<n ;j++)
      { cout <<"*";  }
                    cout<<endl;
                 }
        else
          { cout<<" ";
      for(int k=0 ; k<n ;k++)
       { cout <<"*";}
            cout<<endl;
                  }
            }

          }

    //* CHAP # 2 Q # 18 *//
    //* Enter two integers and show which one is greater*//

    #include <iostream.h>
    void main ()
    { int a,b;
    cout <<"Enter two integers\n";
    cin>>a>>b;
    if(a>b)
    cout <<a<<"greater than"<<b;
    else
    cout <<b<<"greater than"<<a;
    }