Showing posts with label cpp. Show all posts
Showing posts with label cpp. Show all posts

Monday, March 25, 2013

C++ Caesar Cipher File encryption and decryption program source code

C++ program for encrypting and decrypting any file using Caesar cipher and any key entered by the user.

You may even use this as an assignment or mini project in B. Tech. or network security subject by adding little gui and improving the source code.  Feel free to use, modify and share the code... Knowledge is always free !!!
 #include<iostream.h>  
 #include<conio.h>  
 #include<fstream.h>  
 class Caesar  
 {  
     public: void encrypt(char *inp,char *out,int key);  
             void decrypt(char *inp,char *out,int key);  
             void readText(char *inp);  
 };  
 void Caesar::encrypt(char *inp,char *out,int key)  
 {  
     ifstream input;  
     ofstream output;  
     char buf;  
     input.open(inp);  
     output.open(out);  
     buf=input.get();  
     while(!input.eof())  
     {  
         if(buf>='a'&&buf<='z')  
         {  
             buf-='a';  
             buf+=key;  
             buf%=26;  
             buf+='A';  
         }  
         output.put(buf);  
         buf=input.get();  
     }  
     input.close();  
     output.close();  
     readText(inp);  
     readText(out);  
 }  
 void Caesar::decrypt(char *inp,char *out,int key)  
 {  
     ifstream input;  
     ofstream output;  
     char buf;  
     input.open(inp);  
     output.open(out);  
     buf=input.get();  
     while(!input.eof())  
     {  
         if(buf>='A'&&buf<='Z')  
         {  
             buf-='A';  
             buf+=26-key;  
             buf%=26;  
             buf+='a';  
         }  
         output.put(buf);  
         buf=input.get();  
     }  
     input.close();  
     output.close();  
     readText(inp);  
     readText(out);  
 }  
 void Caesar::readText(char *inp)  
 {  
     ifstream input;  
     char buf;  
     input.open(inp);  
     cout<<"\n\n <--- "<<inp<<" --->\n";  
     buf=input.get();  
     while(!input.eof())  
     {  
         cout<<buf;  
         buf=input.get();  
     }  
     input.close();  
 }  
 void main()  
 {  
     Caesar a;  
     int choice,key;  
     char inp[30],out[30];  
     clrscr();  
         cout<<"\n Enter input file: ";  
         cin>>inp;  
         cout<<"\n Enter output file: ";  
         cin>>out;  
         cout<<"\n Enter key: ";  
         cin>>key;  
     cout<<"\n\n 1. Encrypt\n 2. Decrypt\n\n Select choice(1 or 2): ";  
     cin>>choice;  
     if(choice==1)  
         a.encrypt(inp,out,key);  
     else if(choice==2)  
         a.decrypt(inp,out,key);  
     else  cout<<"\n\n Unknown choice";  
     getch();  
 }  

Friday, June 1, 2012

C / C++ (CPP)/ JAVA Projects and Mini Projects | From Idea to Implementation of Source code

C Project Flipkart

Purpose of this post is to guide students at engineering, B.Tech, class 11-12 or even M.C.A. level and to enable them to develop best possible project in C /C++ or JAVA by converting their ideas to actual source code and working program. I will also provide ways by which you can actually do something fruitful through your projects and can help others by making source code of your c/c++ or JAVA mini project open source and available for free download.

C and C++ (cpp) are a popular computer programming language. The C language was given this name because there was a B programming language already and the B language led to the development of C Language. C++ is actually C with classes or C with Objects. C++ means one step ahead of C. ++ is actually traditional unary increment operator in c and cpp that increments the value of a variable by one. So CPP / C++ has all functionalities of C with some additional functionality.

JAVA is another popular object orient programming language developed by James Gosling. It is used widely in different electronic devices including popular mobile devices and operating systems. Main feature of java is platform independence.

Who is in need for downloading free C/C++ (CPP) or JAVA Projects Source Code?

·         Beginners in programming : To show and test their skills
·         Engineering Students: Those doing B.Tech in computer science (CSE), Information Technology (IT) and sometimes even electronics and communication engineers (ECE) are in need of C projects. Students need such projects for their final year 8th semester college work.
·         M.Tech Students
·         M.C.A. and B.C.A Graduates: For academic purposes
·         Class XI and XII CBSE Students: What they need in basic c projects programs for beginners that they can submit in school as assignment.
·         ICSE and ISC Class 9th 10th 11th 12th students looking for JAVA projects in bluej IDE for same reasons.
·         Companies developing actual product for clients.
Some issues related to C/C++/JAVA Project:
·         C/C++/JAVA Project and Mini Project Ideas and Topics. Purpose of any project is to solve any problem. So you must think of some existing problem and then work out a solution. Here are some good ideas that will help you to understand what I am talking about
o   Banking related C Project
o   Railway reservation
o   Library Management System
o   School management
o   Hospital Management
o   Telephone Directory
o   Periodic table Software
o   File Handling concepts
o   Airways Ticket Booking System
o   Share Market Simulation
o   Networking related C/C++ Project : Chat Engine,  Socket programming,  multiplayer game.
o   Simple Games as C or CPP mini project : Tic Tac toe, DOTS.
o   C/C++ Projects with GUI and graphical contents for better Interactions
o   C Projects related to UNIX environment: File search engine.
o   Cryptography
o   Employee details System
o   Database management related C/C++ Projects.
o   AWT or Swing related projects in JAVA
o   JAVA Projects with database connectivity
o   Remote method invocation in JAVA Projects
o   Android Application using JAVA
o   Embedded systems related projects in C language
o   C Microcontroller  related projects
o   C Projects Using OPENGL
o   8051 Related embedded system projects
o   Advanced JAVA projects on Data mining , Cloud computing, Mobile computing
o   J2ME or JSP projects. JDBC and SQL
·         Contents of a good project
o   Proper Source code
o   Projects with good documentation
o   Related Reports
o   Graphical Explanations
·         Free Download C/C++/JAVA Projects online: There are number of websites that can provide you 1000 free projects in these programming languages with source code and even related reports. It is always good to take inspiration and ideas from such resources but it isn’t a good idea to copy the whole project and submit as a pirated assignment. Remember you do project to learn and test your skills by solving some actual practical problem. However it doesn’t mean that you shouldn’t download zip projects from net to make improvements. Beauty of open source is that it allows several developers to contribute so if you want to work on some existing idea and to improve some existing piece of code then go ahead and do that.
·         Gaining knowledge for Projects: There are number of good books to help you gain better understating of concerned programming language. For c/c++ my advice would be Yashavant Kanetkar. And for java complete reference is a good option. There are number of good pdf tutorial s online to help you gain better understating of these programming languages.
·         Distributing Your project
o   Publish it at Google code
o   Publish it at scribd.com with proper license
o   Publish it at you blog
o   Offline distribution to juniors in your institute.

In case you are in need of some help in your c/c++/java project or mini-project you are invited to ping me at my google plus account. I will try my best to solve your problem or will at least refer you to someone who can help you in the regards.

Monday, November 14, 2011

C++/CPP Project : Bingo Game compiled in DEV C++

Bingo game C++ C plus plus source code program


Developed By N. Vivek and Abhas. Financed by Moningi Vivek. Motivation came from Kanishka Anand.


 #include <iostream>
#include <conio.h>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
class card
{
  public:
      int arr[5][5];
      int move(int x);
      int checkwin();
      int cardcheck(int,int);
      void generate();
};
class player:public card
{
  public:
  void input();
  void display();
};
class computer:public card
{
      int q[5];
  public:
      computer();
      void display();
      int play();
};
int card::cardcheck(int i,int j)
{
 if(arr[i][j]<=0 || arr[i][j]>25)
   return 0;
 int k,l;
 for(k=0;k<=i;k++)
 { 
  for(l=0;l<5;l++)
  {
   if(k==i && l==j)
    return 1;
   if(arr[i][j]==arr[k][l])
    {return 0;}
  }    
 }
 return 1;
}
void player::input()
{
  for(int i=0;i<5;i++)
  {
   for(int j=0;j<5;j++)
   {
    cin>>arr[i][j];
    if(!card::cardcheck(i,j))
      {
       cout<<"Invalid Entry:Enter Again !!!";
       j--;
      }
   }
  }
}
void player::display(){
  for(int i=0;i<5;i++)
  {
   for(int j=0;j<5;j++)
   {
    if(arr[i][j]!=0)
    cout<<setw(3)<<arr[i][j];
    else
    cout<<" X";
   }
   cout<<"\n";
  } 
}
void computer::display(){
  for(int i=0;i<5;i++)
  {
   for(int j=0;j<5;j++)
   {
    if(arr[i][j]!=0)
    cout<<" .";
    else
    cout<<" X";
   }
   cout<<"\n";
  } 
}
void card::generate()
{
  for(int i=0;i<5;i++)
  {
   for(int j=0;j<5;j++)
   {
    arr[i][j]=rand()%25 +1;
    if(!cardcheck(i,j))
      {
       j--;
      }
   }
  }
  /*for(int i=0;i<5;i++)
   for(int j=0;j<5;j++)
   cout<<arr[i][j]<<" ";
   */
}
int computer::play()
{
 int i,j,temp;
 for(i=0;i<5;i++)
 {
  for(j=0;j<5;j++)
  {
   if(i<3)
    {
    if(arr[q[i]][j]!=0)
    {
     temp=arr[q[i]][j];
     arr[q[i]][j]=0;
     return temp;
     } 
    }
   else
    {
     if(arr[j][q[i]]!=0)
      {
      temp=arr[j][q[i]];
      arr[j][q[i]]=0;
      return temp;
     }             
    }  
  }
  }
}
computer::computer()
{
  srand(time(0));
  for(int i=0;i<5;i++)
  {
   q[i]=rand()%5;
   for(int j=0;j<i;j++)
    {
     if(q[i]==q[j])
     {
      i--;
      break;
     }
    }  
  } 
  /*for(int i=0;i<5;i++)
  cout<<q[i]<<endl;  */                 
}
int card::move(int x)
{
 for(int i=0;i<5;i++)
  {
   for(int j=0;j<5;j++)
   {
    if(arr[i][j]==x)
    {
      arr[i][j]=0;
      return 1;       
    }
   }
  } 
  return 0;
}
int card::checkwin()
{
 int c=0;
 int i,j;
 for(i=0;i<5;i++)
  {
   for(j=0;j<5;j++)
   {
    if(arr[i][j]==0)
    continue;
    else
    break;
   }
   if(j==5)
    c++;
  }
  for(i=0;i<5;i++)
  {
   for(j=0;j<5;j++)
   {
    if(arr[j][i]==0)
    continue;
    else
    break;
   }
   if(j==5)
    c++;
  }
  if(c==5)
   return 1;
  else
   return 0; 
}
int main()
{  int dh;
 system("color 2F");
 srand(time(0));
 int x,ch;
 player mycard;
 computer compcard;
 do
 {
 compcard.generate();
 cout<<"\t\t##########################################"<<endl;
 cout<<"\t\t#        BINGO          #"<<endl;
 cout<<"\t\t#       Developed by        #"<<endl;
 cout<<"\t\t#                    #"<<endl;
 cout<<"\t\t#   N. Vivek     Abhas Tandon   #"<<endl;
 cout<<"\t\t#                    #"<<endl;
 cout<<"\t\t#               3/11/2011 #"<<endl;
 cout<<"\t\t##########################################"<<endl;
 cout<<"\n\nEnter 1 for Single Player Game(vs Comp.)";
 cout<<"\nEnter 2 for Multiplayer Player Game";
 cout<<"\nEnter 3 to Exit\n";
 cin>>ch;
 if(ch==3)
 break;
 cout<<"Enter 1 if you want to enter numbers manually\nEnter 2 if you want random card\n";
 cin>>dh;
 if(ch==2)
 {
 if(dh==1)
 {
 cout<<"\n\nPlease Input Your Card\n";
 mycard.input();
 mycard.display();
 }
 if(dh==2)
 {
 mycard.generate();
 mycard.display();
 }
 while(!mycard.checkwin())
 {
    cout<<"Enter Number To be Striken:";
    cin>>x;
    while(!mycard.move(x))
    {
     cout<<"Enter Valid Number To be Striken:";
     cin>>x;            
    }
    mycard.display();       
 }
 cout<<"You Won\n";
 getch();
 }
 else if(ch==1)
 {
   int chance=1,t;
   if(dh==1)
 {
 cout<<"\n\nPlease Input Your Card\n";
 mycard.input();
 mycard.display();
 }
 if(dh==2)
 {
 mycard.generate();
 mycard.display();
 }
    while(mycard.checkwin()==0 && compcard.checkwin()==0)
    {
     if(chance==1)
     {
      cout<<"Enter Number To be Striken:";
      cin>>x;
      while(!mycard.move(x))
      {
        cout<<"Enter Valid Number To be Striken:";
        cin>>x;            
      }
      compcard.move(x);
      chance*=-1;
      cout<<"Computer's Card\n";
      compcard.display();
      cout<<"\nYour Card\n";
      mycard.display();
     }
     else
     {
     t=compcard.play();
     cout<<"Computer Has Chosen to strike number "<<t<<endl;
     mycard.move(t);
     cout<<"Computer's Card\n";
     compcard.display();
     cout<<"\nYour Card\n";
     mycard.display();
     chance*=-1;
    }    
 }
 if(mycard.checkwin())
    cout<<"YOU WIN !!!\n";
    else
    cout<<"COMPUTER WINS !!! BETTER LUCK NEXT TIME\n";
    getch();
}
}while(ch!=3);
}