2-D Array In C++

CODE:


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

using namespace std;
void main()
{
int i,j,a[20][20],b[20][20],c[20][20],x,z;
cout<<"Enter no of rows and coloms of matrix A and B :"<<endl;
cin>>x;
cin>>z;
cout<<"Enter the elements of matrix A :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the elements of matrix B :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
c[i][j]=a[i][j]*b[i][j];
}
}
cout<<"The resultant matrix is :"<<endl;
for(i=0;i<x;i++)
{
for(j=0;j<z;j++)
{
cout<<c[i][j]<<"\t";
}
cout<<endl;
}
getch();
}

Continue Reading

TRANSPOSE IN C++

CODE:


#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
       int i,j,k[20][20],l[20][20];
       cout<<"Enter the value of matrix"<<endl;
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cin>>k[i][j];
              }
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cout<<k[i][j]<<"\t";
              }
              cout<<endl;
              }
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     l[j][i]=k[i][j];
              }
       }
       cout<<endl<<endl;
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cout<<l[i][j]<<"\t";
              }
              cout<<endl;
       }
       getch();
       }
Continue Reading

RECURSION IN C++

CODE:


#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<cstdlib>
using namespace std;
int random(int);
void main()
{
     int a;
     cout<<"\n Please enter how many random number you want to generate:";
     cin>>a;
     random(a);
     getch();

}

int random(int num)
{

     if(num<=0)
     {
           return 0;
     }
     cout<<"\n ==>> "<<rand();
     num--;
     random(num);

}

Continue Reading

STUDENT BIO DATA ( THROUGH STRUCTURE )

CODE:


#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string>
using namespace std;
struct student
{
       string name;
       int roll;
       float GPA;
};
int main()
{
       struct student s;
       cout<<"Student Records"<<endl;
       cout<<"Enter name of student : "<<endl;
       getline(cin,s.name);
       cout<<"Enter Roll# of student :"<<endl;
       cin>>s.roll;
       cout<<"Enter GPA of student : "<<endl;
       cin>>s.GPA;
       cout<<"Studnet name : "<<s.name<<endl;
       cout<<"Student roll# : "<<s.roll<<endl;
       cout<<"Student GPA : "<<s.GPA<<endl;
       return 0;
}


Continue Reading

Temperature Conversion Using Pointer

#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;

float Temp_convertor_CtoK(float*);

void main()
{
    float celcius;
    cout<<"\n Enter Temp in Celcius to convert kelvin scale ";
    cin>>celcius;
    //printf("The address is %x",&celcius);
    float result = Temp_convertor_CtoK(&celcius);
    cout<<" \nThe temp in kelvin : "<<result;
    getch();
}

float Temp_convertor_CtoK(float * celciusptr)
{

   float kelvin_temp= (*celciusptr) + 273;
   return kelvin_temp;

   }
Continue Reading

Function Overloading in C++

#include<iostream>
#include<conio.h>
#include<stdio.h>
// put default arg. in any two overloaded function====>>> task  (monday-29)

using namespace std;// not discussed yet.
// Prototype, Declaration
int Tax_Amount(int house_Sq);
int Tax_Amount(int house_Sq, int Vehicle_CC);
int Tax_Amount(int house_Sq, int Vehicle_CC, char Comercial);

void main(void)
{
    int hsq;
    int VCC;
    char com;
    cout<<"\n\n_________Well Come to CDGK Taxation Department System __________ ";
    cout<<"\n\n Plesae Enter House SQ :";
    cin>>hsq;
    cout<<"\n\n Please Enter Vehicle CC : { Enter 0 for N/A } ";
    cin>>VCC;
    cout<<"\n\n Are These Property Use as Comercial:  { Press y = yes, n = no } ";
    cin>>com;
   // Function Calling Work:
    if(VCC==0 && com=='n')
    {
        int tax_Payable = Tax_Amount(hsq);
        cout<<" \n\n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
    }
    if(VCC>0 && com=='n')
    {
        int tax_Payable = Tax_Amount(hsq,VCC);
        cout<<" \n\n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
    }
    if(VCC>0 && com=='y')
    {
        int tax_Payable = Tax_Amount(hsq,VCC,com);
        cout<<" \n Dear Customer Your Net Tax Payable Amount is :  "<<tax_Payable;
    }

}

//Function Defination

int Tax_Amount(int house_Sq)
{
    int Tax=(house_Sq*1000);
    return Tax;

}

int Tax_Amount(int house_Sq, int Vehicle_CC)
{
     int Tax=(house_Sq*1000)+(Vehicle_CC*100);
     return Tax;

}

int Tax_Amount(int house_Sq, int Vehicle_CC, char Comercial)
{
     int Tax=(house_Sq*2000)+(Vehicle_CC*200);
     return Tax;
}
Continue Reading

Transpose of matrix using multi dimenssion Array

#include<iostream>
#include<conio .h="">
#include<stdio .h="">

using namespace std;

void transpose();
void main()
{
 transpose();
 getch();

}
void transpose()
{
 int arra[3][3];
 int arrat[3][3];
 cout&lt;&lt;"\n Enter Array of 3X3 ";
 for(int a=0; a<3 a="" b="" cin="" for="" frm="" input="" int="" user="">&gt;arra[a][b];
  }
 }
 for(int a=0; a</3></stdio></conio></iostream>
Continue Reading