Thursday, 27 February 2014

C++ MATRIX ADD SUBTRACT MULTIPLY DIVIDE OPERATION AND FIND MAXIMUM MINIMUM VALUE IN MATRIX

//CODE

// we make 3 X 4 matrix

/***********************************************************************************/
#include<iostream>
#include<stdlib.h>
#include<cmath>

using namespace std;

void main()
{
    int Matris[3][4];
    int j=0;
    int max_col,max_row,min_col,min_row;
    /**************insert in matrics**************************/
    int i=0;
    while(i<3)//rows<#
    {

        while(j<4)
        {
        cout<<"enter the value of the row and colomn: ["<<i<<"]["<<j<<"]"<<endl;
        cin>>Matris[i][j];
        j++;
        }
        j=0;
        i++;
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/


    /************Showing values in matrices********************/

    cout<<endl<<"----------Values Are in Matrices as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
            //    cout<<"Value Stored in row and colomn of Matric ["<<m<<"]["<<f<<"]"<<" IS : "<<Matris[m][f]<<endl;
            cout<<Matris[m][f];
            }
            if(f!=0 && f!=3)
            {
            cout<<"\t"<<Matris[m][f];
            }
            if(f==3)
            {
            cout<<"\t"<<Matris[m][f]<<endl;
            }
        }
    }


    /************Decleration of new datatype to find maximum and minimum********************/

    int max,min;
    max = min = Matris[0][0];

    cout<<endl<<"\n----------Finding maximum and minimum values----------"<<endl<<endl;
   
   
    //less check
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

    for(int p=0;p<3;p++){
        for(int l=0;l<4;l++){
    {
        if(min>Matris[p][l])
        {
            min = Matris[p][l];
            min_col = p;
            min_row = l;
        }
        if(max<Matris[p][l])
        {
            max = Matris[p][l];
            max_col = p;
            max_row = l;
        }}
        }
    }


    cout<<"Maximum value found in matrices is : "<<Matris[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<Matris[min_col][min_row]<<endl;

    /************************SECOND MATRICS*************************************************/
    int Matris2[3][4];
    i=0,j=0;
    while(i<3)//rows<#
    {

        while(j<4)
        {
        cout<<"enter the value of the row and colomn: ["<<i<<"]["<<j<<"]"<<endl;
        cin>>Matris2[i][j];
        j++;
        }
        j=0;
        i++;
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

    cout<<endl<<"----------Values Are in Matrices # 2 as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
            cout<<Matris2[m][f];
            }
            if(f!=0 && f!=3)
            {
            cout<<"\t"<<Matris2[m][f];
            }
            if(f==3)
            {
            cout<<"\t"<<Matris2[m][f]<<endl;
            }
        }
    }

    max = min = Matris2[0][0];

   
    for(int p=0;p<3;p++){
        for(int l=0;l<4;l++){
    {
        if(min>Matris2[p][l])
        {
            min = Matris2[p][l];
            min_col = p;
            min_row = l;
        }
        if(max<Matris2[p][l])
        {
            max = Matris[p][l];
            max_col = p;
            max_row = l;
        }}
        }
    }
    cout<<"Maximum value found in matrices is : "<<Matris2[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<Matris2[min_col][min_row]<<endl;

    /************************SUM OF MATRICS****************************************************/

    int sumMatrics[3][4];
    for(int z=0;z<3;z++)
    {
        for(int x=0;x<4;x++)
        {
            sumMatrics[z][x] = Matris[z][x] + Matris2[z][x];
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

   
    cout<<endl<<"----------Values Are in SUM MATRICS as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
                cout<<sumMatrics[m][f];
            }
            if(f!=0 && f!=3)
            {
                cout<<"\t"<<sumMatrics[m][f];
            }
            if(f==3)
            {
                cout<<"\t"<<sumMatrics[m][f]<<endl;
            }
        }
    }

    max = min =  sumMatrics[0][0];
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

   
    for(int p=0;p<3;p++)
    {
        for(int l=0;l<4;l++)
        {
            {
                if(min>sumMatrics[p][l])
                {
                    min = sumMatrics[p][l];
                    min_col = p;
                    min_row = l;
                }
                if(max<sumMatrics[p][l])
                {
                    max = sumMatrics[p][l];
                    max_col = p;
                    max_row = l;
                }
            }
        }
    }
    cout<<"Maximum value found in matrices is : "<<sumMatrics[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<sumMatrics[min_col][min_row]<<endl;

    /************************SUBTRACTION OF MATRICS****************************************************/

    int subMatrics[3][4];
    for(int z=0;z<3;z++)
    {
        for(int x=0;x<4;x++)
        {
            if( Matris2[z][x]>Matris[z][x]){
                subMatrics[z][x] =  Matris2[z][x] - Matris[z][x];}
            else
            {subMatrics[z][x] = Matris[z][x]-Matris2[z][x] ;}
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

   
    cout<<endl<<"----------Values Are in SUM MATRICS as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
                cout<<subMatrics[m][f];
            }
            if(f!=0 && f!=3)
            {
                cout<<"\t"<<subMatrics[m][f];
            }
            if(f==3)
            {
                cout<<"\t"<<subMatrics[m][f]<<endl;
            }
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

    max = min =  subMatrics[0][0];

   
    for(int p=0;p<3;p++){
        for(int l=0;l<4;l++){
    {
        if(min>subMatrics[p][l])
        {
            min = subMatrics[p][l];
            min_col = p;
            min_row = l;
        }
        if(max<subMatrics[p][l])
        {
            max = subMatrics[p][l];
            max_col = p;
            max_row = l;
        }}
        }
    }
    cout<<"Maximum value found in matrices is : "<<subMatrics[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<subMatrics[min_col][min_row]<<endl;

    /************************Multiplication OF MATRICS****************************************************/

    int multMatrics[3][4];
    for(int z=0;z<3;z++)
    {
        for(int x=0;x<4;x++)
        {
            multMatrics[z][x] =  Matris2[z][x] * Matris[z][x];
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

   
    cout<<endl<<"----------Values Are in MULTIPLY MATRICS as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
                cout<<multMatrics[m][f];
            }
            if(f!=0 && f!=3)
            {
                cout<<"\t"<<multMatrics[m][f];
            }
            if(f==3)
            {
                cout<<"\t"<<multMatrics[m][f]<<endl;
            }
        }
    }

    max = min =  multMatrics[0][0];

        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

    for(int p=0;p<3;p++){
        for(int l=0;l<4;l++){
    {
        if(min>multMatrics[p][l])
        {
            min = multMatrics[p][l];
            min_col = p;
            min_row = l;
        }
        if(max<multMatrics[p][l])
        {
            max = multMatrics[p][l];
            max_col = p;
            max_row = l;
        }}
        }
    }
    cout<<"Maximum value found in matrices is : "<<multMatrics[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<multMatrics[min_col][min_row]<<endl;

    /************************DIVISION OF MATRICS****************************************************/

    int divMatrics[3][4];
    for(int z=0;z<3;z++)
    {
        for(int x=0;x<4;x++)
        {
            divMatrics[z][x] =  Matris2[z][x] / Matris[z][x];
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

   
    cout<<endl<<"----------Values Are in DIVISION MATRICS as under----------"<<endl<<endl;
    for(int m=0;m<3;m++)
    {
        for(int f=0;f<4;f++)
        {
            if(f==0)
            {
                cout<<divMatrics[m][f];
            }
            if(f!=0 && f!=3)
            {
                cout<<"\t"<<divMatrics[m][f];
            }
            if(f==3)
            {
                cout<<"\t"<<divMatrics[m][f]<<endl;
            }
        }
    }
        /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/

    max = min =  divMatrics[0][0];

   
    for(int p=0;p<3;p++){
        for(int l=0;l<4;l++){
    {
        if(min>divMatrics[p][l])
        {
            min = divMatrics[p][l];
            min_col = p;
            min_row = l;
        }
        if(max<divMatrics[p][l])
        {
            max = divMatrics[p][l];
            max_col = p;
            max_row = l;
        }}
        }
    }
    cout<<"Maximum value found in matrices is : "<<divMatrics[max_col][max_row]<<endl;
    cout<<"Minimum value found in matrices is : "<<divMatrics[min_col][min_row]<<endl;


   
    cout<<"\n\n\t\t\t PRogRam PRO C++ (UMAR JAVED)"<<endl;
    cout<<"\n\n\n\t\t\t***************************"<<endl;
    /*************************COPY RIGHTS TO PROGRAMMINGISBEST/{UMARJAVED01@GMAIL.COM}*********************************************************/
    int h;
    cin>>h;
}


/**************************output**********************************/

//enter the value of the row and colomn: [0][0]
//5
//enter the value of the row and colomn: [0][1]
//1
//enter the value of the row and colomn: [0][2]
//2
//enter the value of the row and colomn: [0][3]
//6
//enter the value of the row and colomn: [1][0]
//11
//enter the value of the row and colomn: [1][1]
//7
//enter the value of the row and colomn: [1][2]
//2
//enter the value of the row and colomn: [1][3]
//6
//enter the value of the row and colomn: [2][0]
//4
//enter the value of the row and colomn: [2][1]
//3
//enter the value of the row and colomn: [2][2]
//8
//enter the value of the row and colomn: [2][3]
//9
//
//----------Values Are in Matrices as under----------
//
//5       1       2       6
//11      7       2       6
//4       3       8       9
//
//
//----------Finding maximum and minimum values----------
//
//Maximum value found in matrices is : 11
//Minimum value found in matrices is : 1
//enter the value of the row and colomn: [0][0]
//11
//enter the value of the row and colomn: [0][1]
//52
//enter the value of the row and colomn: [0][2]
//65
//enter the value of the row and colomn: [0][3]
//75
//enter the value of the row and colomn: [1][0]
//32
//enter the value of the row and colomn: [1][1]
//21
//enter the value of the row and colomn: [1][2]
//25
//enter the value of the row and colomn: [1][3]
//85
//enter the value of the row and colomn: [2][0]
//75
//enter the value of the row and colomn: [2][1]
//65
//enter the value of the row and colomn: [2][2]
//12
//enter the value of the row and colomn: [2][3]
//32
//
//----------Values Are in Matrices # 2 as under----------
//
//11      52      65      75
//32      21      25      85
//75      65      12      32
//Maximum value found in matrices is : 32
//Minimum value found in matrices is : 52
//
//----------Values Are in SUM MATRICS as under----------
//
//16      53      67      81
//43      28      27      91
//79      68      20      41
//Maximum value found in matrices is : 91
//Minimum value found in matrices is : 53
//
//----------Values Are in SUM MATRICS as under----------
//
//6       51      63      69
//21      14      23      79
//71      62      4       23
//Maximum value found in matrices is : 79
//Minimum value found in matrices is : 4
//
//----------Values Are in MULTIPLY MATRICS as under----------
//
//55      52      130     450
//352     147     50      510
//300     195     96      288
//Maximum value found in matrices is : 510
//Minimum value found in matrices is : 50
//
//----------Values Are in DIVISION MATRICS as under----------
//
//2       52      32      12
//2       3       12      14
//18      21      1       3
//Maximum value found in matrices is : 52
//Minimum value found in matrices is : 1



Tuesday, 17 December 2013

C++ Calculate Total days in Year by Input only February days in current year or else year

#include<iostream.h>
#include<conio.h>

void main()
{
int months[11]={31,31,30,31,30,31,31,30,31,30,31};
int fab;
cout<<"How much Days in Fab this year = "; cin>>fab;
int i=0;
int *ptr;
while(i<=11)
{
 fab=fab+months[i];
 ptr=&fab;
 i++;
}
cout<<"total Days this Year Will be = "<<fab;
getch();
}

output :-

Friday, 13 December 2013

C++ Assignment For Air University Student



CS-161 Computer Programming— Fall 2013

BEE                                                    Assignment # 03                                     5th Dec, 2013

                                                Submission Date: 12th Dec, 2013
_____________________________________________________________________________

Q#1   Write a program to keep record of employees personal and payroll information in structure. You should take information of employee name, address, id, served years, and for how many hours he works per day and hourly rate. Think yourself if it needs some nested structure or simple structure. You are required to calculate monthly salary of all 30 employees. Add 20% of salary increment if an employee has over 2 years of experience.

Instructions:

         Do not copy paste
         Submit in hard copy in start of lab
         Copied assignments will be marked Zero
         Total Marks 10
         Late assignment will not be considered




Saturday, 5 October 2013

C++ pointers practice if that no is that then do that!! with the help of point

#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

void main()
{
    int a,b;
    int *ptr;
    int result;
    cout<<"point checking program\n";
    cout<<"if first number is greater then second then ADD \n";
    cout<<"if second number is greater then first then ADD \n";

    cout<<"enter the two numbers:";
        cin>>a>>b;
        if(a>b)
        {
            result = a+b;
            ptr=&result;
        }
        else if(a<b)
        {
            result = a-b;
        ptr = &result;
        }
        else
        {
            cout<<"wrong answer";
        }
        cout<<"value of the result is "<<result;
        cin>>result;
}


c++ Counting Table in which u set limit where to count

#include <iostream>

using namespace std;
int main () {
    int x,a,m;
    cout<<"number for the table to count"<<endl; cin>>a;
    cout<<"pleas enter the limit for upto table to print"<<endl;
    cin>>m;
    for(int i =1;i<=m;i++)
    {
        cout<<a<<" X "<<i<<" = "<<a*i<<endl;
    }
    cout<<endl<<"XXXXXXXXXXXXXXXXXX"<<endl;
}