Pages

💡 Now You Can Get your Assignments Sollution here... .💡 100% plagiarism Free Service...💡 Responsibility, punctuality and on-time delivery... 💡 Furnishing you with experts... 💡 experienced in your subject 100% privacy... 💡 helping you with the highest efficiency , professionalism Affordable and budget-friendly costs that do not make a hole in your wallet

Showing posts with label Random codes. Show all posts
Showing posts with label Random codes. Show all posts

Swapping,Searching, Replacing in array

#include<iostream>
using namespace std;
void swap(int&,int&);
void swap(int [],int[],int);
void swap(char&,char&);
void swap(char[],char[]);
void printarr(const int[],int);
void printarr(const char[]);
int stringlength(char []);
bool searchsubstring(char[],char[]);
bool replacesubstring(char[],char[],char[]);                             //All green lines arfe function prototypes.
void main()                                                                        //main starts here 
{
char array1[100]={'\0'};                       //here both arrayrs array1 & array2 are of size 100 & 10 ,respectively  
char array2[10]={'\0'};                       //and having value NULL on all of its locations
int a=4,b=32;
int a1[5],b1[5];
for(int i=0;i<5;i++)
{
a1[i]=i;
b1[i]=i+5;
}
char ch1,ch2;
ch1='A';
ch2='z';
char arr1[5]={'A','Z','r','Y'};
char arr2[5]={'b','E','i','s'};
cout<<"Without Swap int\n";
cout<<"a:"<<a<<" b:"<<b<<"\n";
swap(a,b);
cout<<"After Swap\n";
cout<<"a:"<<a<<" b:"<<b<<"\n";
cout<<"________________________________________________________\n";
cout<<"Without swap int[]\narr1:";
for(int i=0;i<5;i++)
cout<<a1[i]<<" ";
cout<<"\narr2:";
for(int i=0;i<5;i++)
cout<<b1[i]<<" ";
swap(a1,b1,5);
cout<<"\nAfter swap int[]\narr1:";
for(int i=0;i<5;i++)
cout<<a1[i]<<" ";
cout<<"\narr2:";
for(int i=0;i<5;i++)
cout<<b1[i]<<" ";
cout<<"\n________________________________________________________\n";
cout<<"Without swap char\nch1:";
cout<<ch1;
cout<<"\nch2:";
cout<<ch2;
cout<<"\nAfter swap char\nch1:";
swap(ch1,ch2);
cout<<ch1;
cout<<"\nch2:";
cout<<ch2;
cout<<"\n________________________________________________________\n";
cout<<"Without swap char[]\narr1:";
for(int i=0;i<5;i++)
cout<<arr1[i]<<" ";
cout<<"\narr2:";
for(int i=0;i<5;i++)
cout<<arr2[i]<<" ";
cout<<"\nAfter swap char[]\narr1:";
swap(arr1,arr2);
for(int i=0;i<5;i++)
cout<<arr1[i]<<" ";
cout<<"\narr2:";
for(int i=0;i<5;i++)
cout<<arr2[i]<<" ";
cout<<"\n________________________________________________________\n";
cout<<"print array 1 of int\n";
cout<<"arr1:";
printarr(a1,5);
cout<<"\n________________________________________________________\n";
cout<<"print array 1 of char\n";
cout<<"arr1:";
printarr(arr1);
cout<<"\n________________________________________________________\n";
cout<<"Enter String:";
cin.getline(array1,100,'\n');
cout<<"length on array1 is:"<<stringlength(array1);
cout<<"\n________________________________________________________\n";
cout<<"search substring in array 1 of char string\n";
cout<<"Enter Sub string:";
cin>>array2;
cout<<searchsubstring(array1,array2);
cout<<"\n________________________________________________________\n";
char array3[10];
cout<<"Search and Replace substring in array 1 of char string\n";
cout<<"Enter Sub string:";
cin>>array2;
cout<<"Enter String to Replace:";
cin>>array3;
replacesubstring(array1,array2,array3);
cout<<"\nReplaced array:";
cout<<array1;
cout<<"\n________________________________________________________\n";
}
void swap(int &a,int& b)
{
a=a+b;
b=a-b;
a=a-b;
}
void swap(int a[],int b[],int size)
{
int temp;
for(int i=0;i<size;i++)
{
temp=a[i];
a[i]=b[i];
b[i]=temp;
}
}
void swap(char& c1,char& c2)
{
char temp;
temp=c1;
c1=c2;
c2=temp;
}
void swap(char a[],char b[])
{
char temp;
for(int i=0;i<5;i++)
{
temp=a[i];
a[i]=b[i];
b[i]=temp;
}
}
void printarr(const int a[],int size)
{
for(int i=0;i<size;i++)
cout<<a[i]<<" ";
}
void printarr(const char a[])
{
for(int i=0;i<5;i++)
cout<<a[i]<<" ";
}
int stringlength(char a[])
{
for(int i=0;i<100;i++)
{
if(a[i]=='\0')
return i;
}
return 0;
}
bool searchsubstring(char a[],char b[])
{
int y=strlen(b);
y--;
for(int i=0;i<100;i++)
{
if(a[i]==b[0])
{
for(int j=0;j<10;j++)
{
if(a[i]==b[j])
{
if(y==j)
{
return 1;
}
i++;
}
}
}
}
return 0;
}
bool replacesubstring(char a[],char b[],char c[])
{
int y=strlen(b);
y--;
for(int i=0;i<100;i++)
{
if(a[i]==b[0])
{
for(int j=0;j<10;j++)
{
if(a[i]==b[j])
{
a[i]=c[j];
if(y==j)
{
return 1;
}
i++;
}
}
}
}
return 0;
}

Bank System in Cpp

#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
#include<iomanip>
#include<conio.h>
using namespace std;
void loading(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200]);
void menudisplay(int& accounts, int pin[200], int acnum[200], int funds[200], char acname[200][20], char type[200]);    //prototype for menu function
void createaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200]);    //prototype for creat account function
void depositfunds(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200]);                  //prototype for deposit funnds function
void withdrawfunds(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pins[200]);                 //prototype for withdrawing funds function
void checkbalance(int& accounts, int acnum[200], int funds[200]);                                                         //prototype for checking balance of indivisual account function
void allaccountholders(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20]);                  //prototype for to see all account holders list function
void closeaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200]);                      //prototype for closing an account function
void modifyaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200]);                     //prototype for modifying an account function
void useraccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200]);         //prototype for user can see his account details function
void modify2(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200]);
//***************************************************************
//   the main function of program
//****************************************************************

int main()
{
int pin[200];
char choice;
int accounts = 0;
int acnum[200], funds[200]; char acname[200][20]; char type[200];
int loopvar = 1;
ifstream indata;
indata.open("accounts.txt");
indata >> accounts;
indata.close();
system("color b1");
char  x;
cout << "Do you want to start from 0 accounts , press y for yes .n for no" << endl;
cin >> x;
if (x == 'n' || x == 'N')
{
loading(accounts, acnum, funds, type, acname, pin);
}
if (x == 'y' || x == 'Y')
{
accounts = 0;
}
for (int p = 1; p;)       //for loop to check admin login ,user login ,exit ,,,other wise continue
{
cout << "     .          .  .....  .         ..         ..      .    .      .....\n      .   .    .   .      .       .    .     .    .    ..  ..      .\n       . .  . .    .....  .       .         .      .   . .. .      .....\n        .    .     .      .       .    .     .    .    .    .      .\n                   .....  .....     ..         ..      .    .      ....." << endl;
cin.get();         //a samll function which gives the next operation after pressing "enter"
cout << "\n\n\n                 Admin Login ...press A\n                 User Login .....press U\n                 For Exit press E" << endl;
cin >> choice;
if (choice == 'a' || choice == 'A')
{
do
{
char ch;
int count = 0;
char password[6] = "A^0g0";
string pass;
cout << "Enter the password" << endl;
ch = _getch();           //      this
for (; count<5; count++)     //        will
{                           //             produce
pass.push_back(ch);       //                  stars
cout << '*';           //                         istead of
ch = _getch();            //                               characters of password
}
if (pass == password)
{
loopvar = 0;
menudisplay(accounts, pin, acnum, funds, acname, type);       // calling menu function for admin only
system("CLS");
}
} while (loopvar);    // do_while loop for admin password check
}
if (choice == 'u' || choice == 'U')
{
useraccount(accounts, acnum, funds, type, acname, pin);    //calling user detail function for user only
system("CLS");
}
if (choice == 'E' || choice == 'e')
{
cout << "Thanks for Using Bank Account System" << endl;
p = 0;
}
}
}
//***************************************************************
//     the menu of program
//****************************************************************

void menudisplay(int& accounts, int pin[200], int acnum[200], int funds[200], char acname[200][20], char type[200])
{

int choice = 0;
cout << "*                *                *\n***              ***              ***\n*****            *****            *****\n*******          *******          *******\n*****            *****            *****\n***              ***              ***\n*                *                *" << endl;
for (choice; choice != 8;) //for loop for choice of functions in main menu
{
cout << "\n                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "\n                 Press 1 to create new account" << endl;
cout << "\n                 Press 2 to deposit funds " << endl;
cout << "\n                 Press 3 to withdraw funds" << endl;
cout << "\n                 Press 4 to check balance" << endl;
cout << "\n                 Press 5 to view all account holders" << endl;
cout << "\n                 Press 6 to close an account" << endl;
cout << "\n                 Press 7 to modify an account" << endl;
cout << "\n                 Press 8 to exit program" << endl;
cout << "\n                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cin >> choice;
switch (choice) // switch to connect with required function
{
case 1:
createaccount(accounts, acnum, funds, type, acname, pin);   //calling create account function
system("CLS");
break;
case 2:
depositfunds(accounts, acnum, funds, type, acname,pin);           //calling deposit funds function
system("CLS");
break;
case 3:
withdrawfunds(accounts, acnum, funds, type, acname,pin);        //calling withdraw funds function
system("CLS");
break;
case 4:
checkbalance(accounts, acnum, funds);                        //calling function to check balance of indivisual accounts
system("CLS");
break;
case 5:
allaccountholders(accounts, acnum, funds, type, acname);    //calling all account holders list function
system("CLS");
break;
case 6:
closeaccount(accounts, acnum, funds, type, acname,pin);           //calling close an account function
system("CLS");
break;
case 7:
modifyaccount(accounts, acnum, funds, type, acname,pin);         //calling function to modify an account
system("CLS");
break;
case 8:                                                        //8 for exit
system("CLS");
break;
default:
break;
}
}
}
//***************************************************************
//              create account
//****************************************************************

void createaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200])
{
ofstream outdata;
if (accounts == 0)
{
for (int i = 0; i < 200; i++)       // for loop filling full 2d array with spaces
{
for (int j = 0; j < 20; j++)
{
acname[i][j] = ' ';
}
}
}
if (accounts >199)
{
cout << " you cant save more accounts " << endl; cin.get(); cin.get();
menudisplay(accounts, pin, acnum, funds, acname, type);       // calling menu function for not because accounts are full
}
for (int k = 1; k;)
{
cout << "Account 'number' for User number " << accounts + 1 << endl;
cin >> acnum[accounts];
if (accounts > 0)                                  // if condition and then for loops and then some if conditions to check if account number alreday present
{
for (int f = 0; f < accounts; f++)
{
if (acnum[accounts] == acnum[f])
{
cout << "\nAccount no. Already Present\n" << endl;
k = 1;
break;
}
else
{
k = 0;
}
}
}
else k = 0;
}

if (accounts == 0)
{
outdata.open("acnum.txt");
}
else
outdata.open("acnum.txt", std::fstream::app);
outdata << acnum[accounts] << endl;
outdata.close();
for (int k = 1; k;)
{
cout << "Account 'Name' for User number " << accounts + 1 << endl;
cin >> acname[accounts];
//cin.ignore();
//cin.getline(acname[accounts], 200);
if (accounts > 0)                           // if condition and then for loops and then some if conditions to check if account name alreday present
{
for (int f = 0; f < accounts; f++)
{
if ((strcmp(acname[accounts], acname[f]) == 0))
{
cout << "\nAccount Name Already Present\n" << endl;
k = 1;

}
else
{
k = 0;
}
}
}
else k = 0;
}
if (accounts == 0)
{
outdata.open("acname.txt");
}
else
{
outdata.open("acname.txt", std::fstream::app);
}
outdata << acname[accounts] << endl;
outdata.close();
cout << "Enter Account type < 's' for Saving and 'c' for Current" << endl;
cin >> type[accounts];
if (accounts == 0)
outdata.open("actype.txt");
else
outdata.open("actype.txt", std::fstream::app);
outdata << type[accounts] << endl;
outdata.close();
int h = 1;            //a simple variable
do
{
cout << "Enter the initial amount <500 or more for saving and 1000 or more for current>" << endl;
cin >> funds[accounts];
if (type[accounts] == 's' || type[accounts] == 'S')           //if statement to check account type and then its funds
{
if (funds[accounts] >= 500 && funds[accounts] < 1000)
{
h = 0;
}
}
if (type[accounts] == 'c' || type[accounts] == 'C')           //if statement to check account type and then its funds
{
if (funds[accounts] >= 1000)
{
h = 0;
}
}
}
while (h);
///////////////////////////////////////////
if (accounts == 0)
{
outdata.open("funds.txt");
}
else
outdata.open("funds.txt", std::fstream::app);
outdata << funds[accounts] << endl;
outdata.close();
//////////////////////////////////////////
cout << "Enter the pin code for current" << endl;
cin >> pin[accounts];
if (accounts == 0)
{
outdata.open("pins.txt");
}
else
{
outdata.open("pins.txt", std::fstream::app);
}
outdata << pin[accounts] << endl;
outdata.close();
cout << "Account succesfully created" << endl;
outdata.open("accounts.txt");
accounts++;
outdata << accounts;
outdata.close();
system("CLS");
}
//***************************************************************
//        deposit amount
//****************************************************************

void depositfunds(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200])
{
int acnumd, fundd = 0, counter = 0;
cout << "Enter the account number" << endl;
cin >> acnumd;
for (int i = 0; i < accounts; i++)
{
if (acnum[i] == acnumd)
{

cout << "Account number :" << acnum[i] << endl;
cout << "Account name :" << acname[i] << endl;
cout << "Account type :" << type[i] << endl;
cout << "To deposit amount" << endl;
cout << "                  Enter the amount deposited " << endl;
cin >> fundd;             //entering the amount to add
funds[i] = funds[i] + fundd;
break;
}counter++;
}
cout << "Record updated" << endl; cin.get(); cin.get();
if (counter == accounts){
cout << "Record not found" << endl;              //if statement to check if account not present
}
modify2(accounts, acnum, funds, type, acname, pins);
cin.get(); cin.get();               //a samll function which gives the next operation after pressing "enter"
}
//***************************************************************
//     withdraw funds
//****************************************************************

void withdrawfunds(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200])
{
int acnumd, fundd = 0, counter = 0;
cout << "Enter the account number" << endl;
cin >> acnumd;
for (int i = 0; i < accounts; i++)            //for loop to check the account number and then if present or not
{
if (acnum[i] == acnumd)
{
cout << "Account number :" << acnum[i] << endl;
cout << "Account name :" << acname[i] << endl;
cout << "To withdraw amount" << endl;
cout << "                  Enter the amount withdrawn " << endl;
cin >> fundd;
funds[i] = funds[i] - fundd;
break;
}counter++;
}
cout << "Record updated\n\n" << endl; cin.get(); cin.get();
if (counter == accounts){
cout << "Recrd not found" << endl; //if statement to check if account not present
cin.get(); cin.get();                 //a samll function which gives the next operation after pressing "enter"
}
modify2(accounts, acnum, funds, type, acname, pins);
}
//***************************************************************
//     check balance
//****************************************************************

void checkbalance(int& accounts, int acnum[200], int funds[200])
{
int acnumc;
cout << "Enter the Account Number" << endl;
cin >> acnumc;
for (int i = 0; i < accounts; i++)      //for loop to check the account number and then if present or not
{
if (acnum[i] == acnumc)
{
cout << "Funds are:  " << funds[i];
}
}
cin.get(); cin.get();                       //a samll function which gives the next operation after pressing "enter"
}

//***************************************************************
//     all acount holders
//****************************************************************

void allaccountholders(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20])
{
cout << "\n\n\t\tACCOUNT HOLDER LIST\n\n";
cout << "====================================================\n";
cout << "A/C no.      Name           Type        Balance\n";
cout << "====================================================\n";
for (int i = 0; i < accounts; i++)
{
cout << acnum[i] << "      ";
for (int j = 0; j < 20; j++)
{
cout << acname[i][j];
}cout << "   " << type[i] << "        " << funds[i] << endl;
}
cin.get(); cin.get();                       //a samll function which gives the next operation after pressing "enter"
}
//***************************************************************
//     closing account
//****************************************************************

void closeaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200])
{
int acnumc;
cout << "Enter the Account Number" << endl;
cin >> acnumc;
accounts--;
for (int i = 0; i < accounts; i++)   //for loop to check the account number and then if present or not
{
if (acnum[i] == acnumc)
{
for (int k = i; k < accounts; k++)
{
acnum[k] = acnum[k+1];    //it will replace the account number with zeros
funds[k] = funds[k+1];     //it will replace the account funds with zeros
type[k] = type[k+1];//it will replace the account type with space
pins[k] = pins[k+1];
for (int j = 0; j < 20; j++)
{
acname[k][j] = acname[k+1][j];      //it will replace the account name with spaces
}
}
}
}
ofstream outdata;
outdata.open("accounts.txt");
outdata << accounts;
outdata.close();
modify2(accounts, acnum, funds, type, acname, pins);
cin.get(); cin.get();                //a samll function which gives the next operation after pressing "enter"
}
//***************************************************************
//     modify account
//****************************************************************

void modifyaccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20],int pins[200])
{
int choice, acnumu;
cout << "Enter Your Account Number" << endl;
cin >> acnumu;
for (int k = 0; k < accounts; k++)   //for loop to check the account number and then if present or not
{
if (acnumu == acnum[k])
{
cout << "====================================================\n";
cout << "A/C no.      Name           Type        Balance\n";
cout << "====================================================\n";
cout << acnum[k] << "      ";
for (int j = 0; j < 20; j++)
{
cout << acname[k][j];
}cout << "   " << type[k] << "        " << funds[k] << endl;
cout << "                 what do you want in modification function" << endl;
cout << "                 press 1 to change the name of account" << endl;
cout << "                 press 2 to change the type of account" << endl;
cin >> choice;
switch (choice)           //switch statement to go to required case
{
case 1:
for (int j = 0; j < 20; j++) // for loop filling full 2d array with spaces
{
acname[k][j] = ' ';
}
cout << "enter new name" << endl;
cin >> acname[k];
break;
case 2:
cout << "enter new type" << endl;
cin >> type[k];
break;
default:
break;
}
}
}
modify2(accounts, acnum, funds, type, acname, pins);
cin.get(); cin.get();              //a samll function which gives the next operation after pressing "enter"
}
//***************************************************************
//     user can see his account
//****************************************************************

void useraccount(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200])
{
int acnumu, pinu;
cout << "enter your account number" << endl;
cin >> acnumu;
for (int k = 0; k < accounts; k++)   //for loop to check the account number and then if present or not
{
if (acnumu == acnum[k])
{
cout << "enter the pin code of your account" << endl;
cin >> pinu;
if (pinu == pin[k])    //if statement will match pin of that account which entered pin
{
cout << "====================================================\n";
cout << "a/c no.      name           type        balance\n";
cout << "====================================================\n";
cout << acnum[k] << "      ";
for (int j = 0; j < 20; j++)       // for loop to generate the name
{
cout << acname[k][j];
}cout << "   " << type[k] << "        " << funds[k] << endl;
}
}
}
cin.get(); cin.get();      
//a samll function which gives the next operation after pressing "enter"
}
//***************************************************************
//     loading from files
//****************************************************************

void loading(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200])
{
  string s;
ifstream indata;
indata.open("acnum.txt");
for (int k = 0; k < accounts; k++)
{
indata>>acnum[k];
}
indata.close();
indata.open("acname.txt");
for (int k = 0; k < accounts; k++)
{
  indata >> acname[k];
}
indata.close();
indata.open("pins.txt");
for (int k = 0; k < accounts; k++)
{
indata >> pin[k];

}
indata.close();
indata.open("funds.txt");
for (int k = 0; k < accounts; k++)
{
indata >> funds[k];

}
indata.close();
indata.open("actype.txt");
for (int k = 0; k < accounts; k++)
{
indata >> type[k];

}
indata.close();
}
void modify2(int& accounts, int acnum[200], int funds[200], char type[200], char acname[200][20], int pin[200])
{
ofstream outdata;
outdata.open("acname.txt");
for (int k = 0; k < accounts; k++)
{
outdata << acname[k] << endl;
}
outdata.close();
outdata.open("acnum.txt");
for (int k = 0; k < accounts; k++)
{
outdata << acnum[k] << endl;
}
outdata.close();
outdata.open("actype.txt");
for (int k = 0; k < accounts; k++)
{
outdata << type[k] << endl;
}
outdata.close();
outdata.open("funds.txt");
for (int k = 0; k < accounts; k++)
{
outdata << funds[k] << endl;
}
outdata.close();
outdata.open("pins.txt");
for (int k = 0; k < accounts; k++)
{
outdata << pin[k] << endl;
}
outdata.close();


}

Vowel Counter

#include <iostream>
#include <string.h>
using namespace std;

#define MAX 100

//prototypes / function(s) declaration
void input(char line[]);
void proc(char line[],int& vow,int& a,int& e,int& i,int& o,int& u);
void display(const int& vow,const int& a,const int& e,const int& i,const int& o,const int& u);


int main()
{
 system("color f0"); //for changing the color of output screen

//declaration / initialization
 char line[MAX];
 int vow=0,a=0,e=0,i=0,o=0,u=0;

//function(s) calling
 input(line);
 proc(line,vow,a,e,i,o,u);
 display(vow,a,e,i,o,u);

 system("pause");
}//end of main

void input(char line[])
{
 cout<<"Enter the line of text to FINISH press Enter Key : \n";
 cin.getline(line,MAX);
}//end of input

void proc(char line[],int& vow,int& a,int& e,int& i,int& o,int& u)
{
 int len=strlen(line); //getting the length of string
 for(int n=0; n<len-1;n++)
 {
  if((line[n]=='A')||(line[n]=='a'))
  {
   vow++;
   a++;
  }
  else if((line[n]=='E')||(line[n]=='e'))
  {
   vow++;
   e++;
  }
  else if((line[n]=='I')||(line[n]=='i'))
  {
   vow++;
   i++;
  }
  else if((line[n]=='O')||(line[n]=='o'))
  {
   vow++;
   o++;
  }
  else if((line[n]=='U')||(line[n]=='u'))
  {
   vow++;
   u++;
  }
 }//end of for

}//end of proc


void display(const int& vow,const int& a,const int& e,const int& i,const int& o,const int& u)
{
 cout<<"\n\nVowels found = "<<vow
  <<"\n\n'A' found = "<<a
  <<"\n'E' found = "<<e
  <<"\n'I' found = "<<i
  <<"\n'O' found = "<<o
  <<"\n'U' found = "<<u<<endl<<endl;
}

C++ Code for Pattren

#include<iostream>
using namespace std;
void main()
{
int c=77,d=78,e=0;
for(int j=1;j<=24;j++)
{
for(char i=65;i<=c;i++)
{
cout<<i;
}
for(int i=1;i<=e;i++)
{
cout<<" ";
}
for(char i=d;i<=90;i++)
{
cout<<i;
}
d++;
c--;
e=e+2;
cout<<endl;
}
}
           Output:

C++ Code for Pattren

#include<iostream>
using namespace std;
void main()
{
int n=1,c=4,l=1;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=c;j++)
{
cout<<" ";
}
for(int k=1;k<=n;k++)
{
cout<<l<<" ";
l++;
}
cout<<endl;
c--;
n++;
}
}

Output:
    1
   2 3
  4 5 6
7 8 9 10

C++ code to calculate Time

 #include<time.h>

clock_t start = clock();

/*
your code 
*/
clock_t end = clock();
double time = (double) (end-start) / CLOCKS_PER_SEC * 1000.0;
cout<<time<<endl;

Addition of Two Matrix

Using the functions of task 2 to create another 2-D array of user defined size. Add this
2-D array to the 2-D array created in task 2 and store the result in 3rd 2-D array. Be careful
because both the arrays may be of different sizes so the 3rd array should be able to hold
the result properly



#include<iostream>
using namespace std;
void output2 (int n1,int m1,int** dpp)
{
for(int i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
cout<<dpp[i][j]<<" ";

}
cout<<endl;
}
}
void task4(int n1,int m1,int** dppp,int N,int M,int **dp)
{
bool found=false;
int**dpp;
int r=0,c=0;
if(n1>N)
r=n1;
else r=N;
if(m1>M)
c=m1;
else c=M;
dpp = new int*[r];
for( int i=0; i<r; i++)
dpp[i]=new int[c];
for( i=0; i<r; i++)
{
for(int j=0; j<c;j++)

{
if(dp[i][j]==true && dppp[i][j]==true)
{
dpp[i][j]= dp[i][j]+dppp[i][j];
}
}
}
output2(r,c,dpp);

}
void output1 (int n1,int m1,int** dppp,int n,int m,int**dp)
{
for(int i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
cout<<dppp[i][j]<<" ";

}
cout<<endl;
}
cout<<endl;
task4( n1, m1,dppp, n, m,dp);
}

void input1(int n1,int m1,int **dp,int n,int m)
{
int **dppp;
cout<<"enter the no of rows : ";
cin>>n1;
cout<<endl<<"enter the number of columns : ";
cin>>m1;
dppp = new int*[n1];
for(int i=0; i<n1; i++)
dppp[i]=new int[m1];
for( i=0; i<n1; i++)
{
for(int j=0; j<m1;j++)
{
dppp[i][j]= rand()%10;
}
}
output1(n1,m1,dppp,n,m,dp);
}

void output (int n,int m,int** dp,int n1,int m1)
{
for(int i=0; i<n; i++)
{
for(int j=0; j<m;j++)
{
cout<<dp[i][j]<<" ";

}
cout<<endl;
}
input1(n1,m1,dp,n,m);
}

void input(int n, int m,int n1,int m1)
{
int**dp;
cout<<"enter the no of rows : ";
cin>>n;
cout<<endl<<"enter the number of columns : ";
cin>>m;
dp = new int*[n];
for(int i=0; i<n; i++)
{
dp[i]=new int[m];
}
for(int k=0; k<n; k++)
{
for(int j=0; j<m;j++)
{
dp[k][j]= rand()%10;
}
}
output(n,m,dp,n1,m1);
}
int main()

{

int n=0,n1=0,m1=0,m=0;
input(n,m,n1,m1);
system("pause");
return 0;

}