Tuesday, 15 March 2016

Program To Print The Mirror Image of an Array in C++

"Nice One Program"

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

void main()
{  clrscr();
  int a[7][7];  int r,col;
  cout<<"Enter The number Of Rows and Columns:";
  cin>>r;
  cout<<endl;
  cin>>col;

  cout<<"\n\n";
  cout<<"Enter The Elements Row wise\n";

  int i,j;

  for(i=0;i<r;i++)
  for(j=0;j<col;j++)     //Array Input
  cin>>a[i][j];

cout<<"\n\n";

  for(i=0;i<r;i++)
{ cout<<endl;
  for(j=0;j<col;j++)
  cout<<a[i][j]<<" "; //Printing Original

  cout<<"-->";

  for(j=col-1;j>=0;j--) //Printing Mirror Img
  cout<<a[i][j]<<" ";

}
getch();

}




Thursday, 3 March 2016

Ceaser Cipher Program in C++

"Nice One Program"

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

void main()
{ clrscr();
  int choice,l;
  char a[10];
  cout<<"Enter Choice:\nCODING:1\nDECODING:2\nChoice:";
  cin>>choice;

  int i,t;
  if(choice==1)
  { cout<<"Enter Object:";
   cin>>a;
   l=strlen(a);

 for(i=0;i<l;i++)
  a[i]=toupper(a[i]);

   for(i=0;i<l;i++)
   { t=a[i];
     if(t==90)
     { a[i]=67;
      cout<<a[i]<<" ";
     }
     else if(t==89)
     {a[i]=66;
      cout<<a[i]<<" ";
     }
     else if(t==88)
     {a[i]=65;
      cout<<a[i]<<" ";
     }

     else
     { a[i]=t+3;
      cout<<a[i]<<" ";
     }

   }
  }//END Of Coding

  else if(choice==2)
  {cout<<endl<<"Enter The CODED Form:";
   cin>>a;
   l=strlen(a);
   for(i=0;i<l;i++)
   a[i]=toupper(a[i]);

   for(i=0;i<l;i++)
  { t=a[i];

    if(t==65)
    { a[i]=88;
     cout<<a[i]<<" ";
    }
    else if(t==66)
    { a[i]=89;
     cout<<a[i]<<" ";
    }
    else if(t==67)
    { a[i]=90;
     cout<<a[i]<<" ";
    }


     else
    { a[i]=t-3;
    cout<<a[i]<<" ";
    }
   }
  }// END OF DECODER


    getch();


}






PLEASE COMMENT DOWN FOR ANY PROBLEM REGARDING CODE
WE WILL SURELY HELP YOU.. THANK YOU FOR VISITING
KEEP VISITING FOR MORE QUESTIONS AND THEIR CODES.

Please Share This Page...