Monday, 1 September 2014

How to copy text in CMD?

Most of us are aware that in CMD (Command Prompt) paste is achieved by a right click. Then what about copying something from CMD itself. It is obvious that this is not possible by a CTRL+C command as it is for terminating a process in CMD. So lets learn how to do this!


  • Open CMD just by typing cmd in search
  • Then right click at title bar as shown in figure
  • Go to properties and find edit options. 
  • Check on the Quick Edit Mode option and click OK.
  • Over!!! Now select the text you want to copy as you would do in any other text editor and right click on it. Paste it in your text editor! Simple!!
Note that you can't select text in CMD without checking on the Quick Edit Mode option!



Friday, 11 July 2014

C++ program to output alternate letters and numbers for a given input string

This program's aim is :

  • when user inputs: abcd7123, output should be: a7b1c2d3.
  • if no.of letters are more than numbers or vice verse then remaining substring of greater string should be followed. eg: if i/p=abc12345 then o/p=a1b2c345 or if i/p=abcd12 then o/p=a1b2cd

  1 #include<iostream> 
  2 #include<ctype.h> 
  3 using namespace std;
  4 void print_remain(char *,int); 
  5 void print(char *, char *,int); 
  6 int main() 
  7 { 
  8     char a[10]={},b[10]={},c[50]; 
  9     cout<<"Enter the string"; 
 10     cin>>c; 
 11     int len=strlen(c); 
 12     int i=len,l=-1,m=-1,n=0; 
 13     while(i) 
 14     { 
 15         if(isalpha(c[n])) 
 16         { 
 17             l++; 
 18             a[l]=c[n]; 
 19         } 
 20         else 
 21         { 
 22             m++; 
 23             b[m]=c[n]; 
 24         } 
 25         i--;n++; 
 26     } 
 27  
 28     i=len,l=0,m=0,n=0; 
 29     int len_a=strlen(a),len_b=strlen(b); 
 30     if(len_a==len_b) 
 31         print(a,b,len); 
 32     else if(len_a<len_b) 
 33     { 
 34         print(a,b,len_a); 
 35         print_remain(b,len_a); 
 36     } 
 37     else 
 38     { 
 39         print(a,b,len_b); 
 40         print_remain(a,len_b); 
 41     } 
 42     return 0;
 43 } 
 44 void print(char *a, char *b, int i)
 45 { 
 46     int j=0,k=0; 
 47     while(i) 
 48     { 
 49         cout<<a[j]<<b[k]<<" "; 
 50         j++;k++;i--; 
 51     } 
 52 } 
 53 void print_remain(char *str, int indx)
 54 { 
 55     int i=strlen(str); 
 56     while(i-indx) 
 57     { 
 58         cout<<str[indx]; 
 59         indx++; 
 60     } 
 61  
 62 }

A Simple C++ program based on strings

Aim of this program is...when a user gives input consisting of letters followed by numbers...eg: a2b3 then output should be aabbb
  1 #include<iostream> 
  2 #include<ctype.h> 
  3 using namespace std;
  4 int main() 
  5 { 
  6     char str[50],a;
  7     cout<<"Enter a string: "; 
  8     cin>>str; 
  9     int len=strlen(str),rep,j=0; 
 10     int i=len/2;
 11      
 12     while(i) 
 13     { 
 14          
 15         a=str[j]; 
 16         rep=(str[j+1])-'0'; 
 17          
 18         while(rep) 
 19         { 
 20             cout<<a; 
 21             rep--; 
 22         } 
 23         i--;j=j+2; 
 24     } 
 25      
 26     return 0;
 27 }
Have a nice day!!

Sunday, 4 May 2014

Guess the number game in PYTHON!!

Well, we love to guess and we feel happy if our guess is right.
This game is based on your guess. Computer randomly selects a number and you have to guess the number.
Simple!! Isn't it?? But you are give limited chances based on your range. So test your intuition with this game!!!
This game is written in python and output of the program will be as shown in figure:

The program is as follows:

import simplegui
import random
secret_number=0
secret_number1=0
secret_number2=0
remaining_100=0
remaining_1000=0
remaining=0
def new_game():
    global secret_number1,secret_number2,remaining_100,remaining_1000
    secret_number1=random.randrange(0,100)
    secret_number2=random.randrange(0,1000)
    remaining_100=7
    remaining_1000=10

def range100():
    
    global secret_number1,secret_number2,remaining_100,remaining,secret_number 
    new_game()
    secret_number=secret_number1
    remaining=remaining_100
    
def range1000():
   
    global secret_number1,secret_number2,remaining,remaining_1000,secret_number 
    new_game()
    secret_number=secret_number2
    remaining=remaining_1000
    
    
def input_guess(guess):
    global remaining,secret_number
    
    remaining=remaining - 1
    if(secret_number>int(guess)):
        print "Guess was: ",int(guess)
        print "No.of remaining choices: ",remaining
        print "Higher!!"
        
    elif(secret_number<int(guess)):
        print "Guess was: ",int(guess)
        print "No.of remaining choices: ",remaining
        print "Lower!!"
    else:
        print "Your guess was: ",int(guess)
        print "You win!!!"
    if(remaining==0):
        print "You lose!!"
        
        
frame=simplegui.create_frame("Guess the number!!!",300,300)
frame.add_input("Enter the guess",input_guess,150)
frame.add_button("Range of 0-100",range100,150)
frame.add_button("Range of 0-1000",range1000,150)
frame.start()

Saturday, 3 May 2014

Rock-Paper-Scissor-Lizard-Spock game in PYTHON

The key idea of this game is as follows:
It's very simple:

  1. Scissors cuts paper
  2. Paper covers rock
  3. Rock crushes lizard
  4. Lizard poisons Spock
  5. Spock smashes scissors
  6. Scissors decapitates lizard
  7. Lizard eats paper
  8. Paper disproves Spock
  9. Spock vaporizes rock
  10. Rock crushes scissors
The program is as follows:


# Rock-paper-scissors-lizard-Spock template


# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors


import random
import math
def name_to_number(name):
    
    if(name=="rock"):
        num=0
    elif(name=="spock"):
        num=1
    elif(name=="paper"):
        num=2
    elif(name=="lizard"):
        num=3
    elif(name=="scissors"):
        num=4
    else:
        num=None
    return num



def number_to_name(number):
   
    if(number==0):
        name="rock"
    elif(number==1):
        name="spock"
    elif(number==2):
        name="paper"
    elif(number==3):
        name="lizard"
    elif(number==4):
        name="scissors"
    else:
        name=None
    return name

   
    

def rpsls(player_choice): 
    
    
    # print a blank line to separate consecutive games
    print
    # print out the message for the player's choice
    print "Player's choice: ", player_choice
    # convert the player's choice to player_number using the function name_to_number()
    player_number=name_to_number(player_choice)
    # compute random guess for comp_number using random.randrange()
    comp_number=random.randrange(0,5)
    # convert comp_number to comp_choice using the function number_to_name()
    comp_choice=number_to_name(comp_number)
    # print out the message for computer's choice
    print "Computer's choice: " , comp_choice
    # compute difference of comp_number and player_number modulo five
    
    result=(comp_number-player_number)%5
    if(result>=0):
        if(result>=3):
            print "Player wins"
        elif(result==0):
            print "There is a tie"
        else:
            print "Computer wins"
    else:
        if(result>-3):
            print "Computer wins"
        else:
            print "Player wins"
        
   
    
# test your code 
rpsls("rock")
rpsls("spock")
rpsls("paper")
rpsls("lizard")
rpsls("scissors")

Thursday, 6 February 2014

Playing with zeroes in matrices

It is one of the simplest tasks in C++. If an element in a matrix is found to be zero, then make its corresponding row and column to zeroes. Here is the code for the above task.

  1 #include<iostream> 
  2 using namespace std;
  3 class matrix 
  4 { 
  5     int a[50][50]; 
  6     int n,m; 
  7 public: 
  8     matrix(int rows,int cols) 
  9     { 
 10         n=cols; 
 11         m=rows; 
 12         **a=0; 
 13     } 
 14     void create() 
 15     { 
 16         cout<<"Enter elements: "; 
 17         for(int i=0;i<m;i++) 
 18         { 
 19             for(int j=0;j<n;j++) 
 20             { 
 21                 cin>>a[i][j]; 
 22             } 
 23         } 
 24     } 
 25     void zero() 
 26     { 
 27         int *rows=new int[m]; 
 28         int *cols=new int[n]; 
 29          
 30         for(int i=0;i<m;i++) 
 31         { 
 32             for(int j=0;j<n;j++) 
 33             { 
 34                 if(a[i][j]==0) 
 35                 { 
 36                     rows[i]=1; 
 37                     cols[j]=1; 
 38                 } 
 39             }                 
 40                      
 41         } 
 42      
 43         for(int i=0;i<m;i++) 
 44         { 
 45             for(int j=0;j<n;j++) 
 46             { 
 47                 if(rows[i]==1||cols[j]==1) 
 48                     a[i][j]=0; 
 49             } 
 50         } 
 51     } 
 52     void display() 
 53     { 
 54         for(int i=0;i<m;i++) 
 55         { 
 56             for(int j=0;j<n;j++) 
 57             { 
 58                 cout<<a[i][j]<<" "; 
 59             } 
 60             cout<<endl; 
 61         } 
 62     } 
 63  
 64 }; 
 65 int main() 
 66 { 
 67     int x,y; 
 68     cout<<"Enter rows and cols: "; 
 69     cin>>x>>y; 
 70     matrix m(x,y); 
 71     m.create(); 
 72     m.zero(); 
 73     cout<<"\nAfter change:\n"; 
 74     m.display(); 
 75     return 0;
 76 }
If there are any suggestions, please feel free to comment........See you again with a new challenge 

Sunday, 2 February 2014

Top 5 Launchers of 2013

Here are the top 5 Android Launchers for 2013 in ascending order. Download them in Google Play store and make your phone trendy and on par with modern world!!

#5 Smart Launcher:



 Smart Launcher is an innovative launcher characterized by a minimalist design, low memory usage and an user-friendly UI that let you start any application with a few taps.
 It has some of the following benefits:
  1. Main screen with quick start
  2. Ready to use without much configurations
  3. Support Live wallpapers for different sizes
  4. Fast search
  5. Landscape mode
  6. Easy access to app's info

#4 Bazooka Launcher:

Bazooka is based on Cyanogen’s Trebuchet Launcher — which comes stock with modern CyanogenMod ROMs.

Benefits:

  1. Fast and stable
  2. You can quickly download and apply themes
  3. Gesture support
  4. Fancy lock screen 








#3 Ez Launcher:


It is a cool launcher app which makes convenient to operate and organize your phone

Benefits:

  1. Genius app lets you access the most frequently visited apps.
  2. It automatically categorizes your apps
  3. Quick search is enabled to search your app easily
  4. Pre-loaded app manager tool
  5. Useful and handy widgets 




#2 Action Launcher:


Benefits:

  1. A sliding quick drawer for instant access of all your apps.
  2. Translucent navigation and status bar
  3. Quick search which allows to search apps and music directly from action bar.
  4. Strong play store integration.
  5. Full Tablet support
  6. Icon pack and Icon scaling support.

#1 Next launcher 3D:


Next Launcher 3D gives you a new experience of 3D vision pushing back traditional flat launcher.

Benefits:

  1. Fancy 3D effects with smooth experience.
  2. 3D transitions of home screens.
  3. Mind blowing and stunning 3D screen preview
  4. Build unique icon style by changing  size,angle, and location of that icon
  5. Shinny border experience for screen transitions
  6. Floating mode of icons.
Here is a video regarding these launchers:

Saturday, 1 February 2014

Check whether two strings are anagrams or not in c++

Here's the code to check if two strings are anagrams to each other or not...But I personally feel this could be more efficient. So please do comment if you find efficient solution. This program works for every test cases.

  1 #include<iostream> 
  2 using namespace std;
  3 bool anagram(char*,char*); 
  4 int main() 
  5 { 
  6     char s1[100],s2[100];
  7     cout<<"Enter string 1: "; 
  8     gets(s1); 
  9     cout<<"Enter string 2: "; 
 10     gets(s2); 
 11     if(anagram(s1,s2)) 
 12     { 
 13         cout<<"The two strings are anagrams! "; 
 14     } 
 15     else 
 16     { 
 17         cout<<"The two strings are not anagrams! "; 
 18     } 
 19     return 0;
 20 } 
 21 bool anagram(char*s,char*t) 
 22 { 
 23     int l1=strlen(s); 
 24     int l2=strlen(t); 
 25     if(l1!=l2) 
 26         return false; 
 27     int count1[256]={0},i,count2[256]={0}; 
 28     for(i=0;s[i]&&t[i];i++) 
 29     { 
 30         count1[s[i]]++; 
 31         count2[t[i]]++; 
 32     } 
 33     for(i=0;i<256;i++) 
 34     { 
 35         if(count1[i]!=count2[i]) 
 36             return false; 
 37     } 
 38     return true; 
 39 } 
 

Thursday, 30 January 2014

Find your Lost Android Phone

A lost phone is worrisome. You would fear that someone misuse your phone pushing you in serious troubles. I'm not talking about SIM, because you can block that. But what if you have very vital information stored in your phone??! Then definitely it is a serious issue. Prevention is better than cure. First of all implement the following steps:

  1. Go to Settings->Security->Device Administrators->Android Device Manager
  2. Tap on it and activate it.
  • Now if your phone is lost, go to google play store
  • There you can see a gear like button on the top right corner of your page, click on it and select Android Device Manger
You have 3 options:

  • Ring: You can ring your phone
  • Lock your phone
  • Erase all data: This will erase all data but not SD card. Also  Android Device Manger wont work if you erase the data


  • Tuesday, 28 January 2014

    Replace spaces in a string with %20

    Here's the code to replace all the spaces with %20 in a given string.

      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     int i,len,count=0; 
      6     char *str; 
      7     str=new char[100]; 
      8     cout<<"Enter your string: "; 
      9     gets(str); 
     10     len=strlen(str); 
     11     for(i=0;i<len;i++) 
     12     { 
     13         if(str[i]==' ') 
     14             count++; 
     15     } 
     16     int newlength=len+count*2; 
     17     str[newlength]='\0'; 
     18     for(i=len-1;i>=0;i--) 
     19     { 
     20         if(str[i]==' ') 
     21         { 
     22             str[newlength-1]='0'; 
     23             str[newlength-2]='2'; 
     24             str[newlength-3]='%'; 
     25             newlength=newlength-3; 
     26         } 
     27         else 
     28         { 
     29             str[newlength-1]=str[i]; 
     30             newlength=newlength-1; 
     31         } 
     32     } 
     33     cout<<"String after replacing: "; 
     34     puts(str); 
     35     return 0;
     36 } 

    Removing duplicates from the string

    Here's the code to remove duplicates from a given string. In this program, I've used a variable called tail which is used to remove all the duplicates and also acts as boundary for string comparison.


      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     char *str; 
      6     str=new char[50]; 
      7     cout<<"enter"; 
      8     cin>>str; 
      9     int tail = 1,len;
     10     len=strlen(str); 
     11      for (int i = 1; i < len; ++i) {
     12         int j; 
     13         for (j = 0; j < tail; ++j) {
     14              if (str[i] == str[j]) break;
     15          } 
     16         if (j == tail) { 
     17             str[tail] = str[i]; 
     18             ++tail; 
     19          } 
     20     } 
     21  str[tail] = 0; 
     22  for(int i=0;i<len;i++) 
     23      cout<<str[i]; 
     24  return 0;
     25 }
    I appreciate your suggestions if any....Thank you

    Reverse a String

    Here's a program to reverse a string. Although I'm not sure about the time complexity, this program has worked well

      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     char *a, *b,c; 
      6     int i,j; 
      7     cout<<"Enter: "; 
      8     a=new char[50]; 
      9     b=new char[50]; 
     10     cin>>a; 
     11     int l=strlen(a); 
     12      
     13     for(i=0,j=l-1;i<l-1,j>0,i<j;i++,j--) //Swap last and first characters
     14     { 
     15         c=a[i]; 
     16         a[i]=a[j]; 
     17         a[j]=c; 
     18     } 
     19     for(i=0;i<l;i++) 
     20         cout<<a[i]; 
     21     return 0;
     22 } 
         

    Friday, 24 January 2014

    Program to determine if a string has unique characters

    This is a simple program to check if all the characters in a string are unique or not if no additional data structure is provided.
      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     int i,l,j; 
      6     bool f=true; 
      7     char a[50];
      8     cout<<"Enter: "; 
      9     gets(a); 
     10     l=strlen(a); 
     11     for(i=0;i<l;i++) 
     12     { 
     13         for(j=l-1;i<j;j--) 
     14         if(a[i]==a[j]) 
     15         { 
     16             f=false; 
     17             break; 
     18         } 
     19     } 
     20     if(f) 
     21         cout<<"All unique"; 
     22     else 
     23         cout<<"Not unique"; 
     24     return 0;
     25 } 
     26 

    Saturday, 18 January 2014

    Bugs!!

    Do you know how the name bug came into picture in computer world??? In computer world, a bug is a "mistake" in a program whereas in real world, a bug is kind of "moth". Then how these two were related?? Here is the answer:

    In early days of computer, when its hardware is very sensitive, a small moth caused a relay to fail when Aiken, Hopper were working on Harvard Mark1 computer. Hopper and other programmers taped the deceased moth in a log book with the note "First actual case of bug being found."

    The log book is currently on the display at Navel Museum in Dahlgren, Virginia. This was the first computer documented bug.

    Professor Aiken would come into the facility during a slack time and inquire if any numbers were being computed. Then the programmers would reply that they were debugging the computer!!!!!

    In this way we bug came into computer world !!


    Facebook Themes


    The other day I was searching for some apps in google play store and I found themes for Facebook. It was surprise to me but that did last only few minutes because of the poor layouts. Themes shown in gallery and themes applied to facebook account were different. Also facebook icon i.e.  is completely removed and the new layout is completely misplaced in some themes...so be selective in choosing these themes and not all are good! For those who want to try have a look:

    1. Go to chrome webstore and search for Facebook themes and download the one with facebook icon shown here: .
    2. Now after installation type chrome://extensions in address bar and search for facebook themes.
    3. In options click on explore and install your favorite theme it takes just a second!
    4. Go to your facebook account and you can see the applied theme.


    5. If you want to switch to default, just go to installed tab and click on disable!

    Friday, 17 January 2014

    Restore Whatsapp Messages

    We all use Whatsapp and no doubt we love it!! But some times we accidentally delete our important messages in Whatsapp! And you don't know what to do next.
    There are two methods to restore those messages.

    Method 1:

    1. First of all, go to sdcard/WhatsApp/Databases in your sdcard. 
    2. Here you will two files for example: msgstore-2014-01-07.db.crypt and msgstore.db.crypt. Rename the second file i.e. msgstore.db.crypt by adding some word.
    3. After that select the file msgstore-2014-01-07.db.crypt and rename it to  msgstore.db.crypt
    4. Finally, go to Settings/Applications/Manage applications/WhatsApp and click on Clear Data.
    5. Now open WhatsApp and it asks to restore messages. Click on restore.



    Method 2:

    There is also another method using web application called Recover Messages. Visit that site and click on Select SQlite File to upload your msgstore-2014-01-07.db.crypt file and select Scan. (Don't forget to check the box I accept the terms of use) It takes few seconds and you can read all your messages.



    The drawback in this second method is that messages are not restored in your chat history instead you can only extract and read them!


    Saturday, 11 January 2014

    Download java sdk

    Downloading java is not similar to any other interface. For example to download turbo C, you just need to download turbo C software and no need to make any changes in your computer. But for java to work we have to make some changes as Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture.

     So just follow the steps give below:

    Step 1: To download java click here. Make sure that you download Java SE (Standard Environment) not netbeans.
    Step 2: After that you will get two filles: 1) jdk1.7.0_45 2) jre7
    If you type javac in your command prompt it says that java is not recognized even if it is downloaded in your system
    Step 3: Goto to jdk1.7.0_45----->bin------->copy the location of the file.
    Step 4: Goto my computer and right click to go in properties.
    Step 5: Then in advanced settings click on environment variables and click on new.
    Step 6: Give the name exactly as "Path" (without quotes) and paste the address that you have copied in step 3 and click on OK.
    Now go to command prompt and type javac. You will see all the files related to java!
    A video is provided here. You can follow it if you are bit confused!



    Friday, 10 January 2014

    Ghost Keyboard Typing

    Hello, now I'm going to share you how to prank your friend with notepad!!!
    Yes! You heard it right! with "NOTEPAD"...just follow the steps...


    Step 1: Open notepad.
    Step 2: Copy the below code exactly in your notepad.

    set wshshell = wscript.CreateObject("wScript.Shell")
    wshshell.run "Notepad"
    wscript.sleep 400
    wshshell.sendkeys "H"
    wscript.sleep 100
    wshshell.sendkeys "E"
    wscript.sleep 120
    wshshell.sendkeys "L"
    wscript.sleep 200
    wshshell.sendkeys "L"
    wscript.sleep 100
    wshshell.sendkeys "L"
    wscript.sleep 140
    wshshell.sendkeys "O"
    wscript.sleep 100
    wshshell.sendkeys " "
    wscript.sleep 50
    wshshell.sendkeys "W"
    wscript.sleep 120
    wshshell.sendkeys "O"
    wscript.sleep 170
    wshshell.sendkeys "R"
    wscript.sleep 100
    wshshell.sendkeys "L"
    wscript.sleep 50
    wshshell.sendkeys "D"
    wscript.sleep 120
    wshshell.sendkeys "!"
    wscript.sleep 160
    wshshell.sendkeys "!"
    wscript.sleep 200
    wshshell.sendkeys "!"
    wscript.sleep 100


    Step 3: Now save the file as Hello.vbs (Don't forget the extension .vbs)
    Step 4: Double click the saved file and see the magic!

    Note: If you get any error regarding "Line" or "Char" then you just right click the saved file and go to edit option. Remove all quotation marks (") and re-type them manually and save it. Now repeat step 4. 

    Understand Computers!

    Computers have become an important and indispensable feature of our lives. Ever since its inventions few decades ago and the subsequent introduction of the Internet, it has become an essential tool for many students and adults alike. Computer is used at work and even at schools which usually have computer laboratories. Computers are every where


    Its not late to start learning computers now! Of-course even a 4th standard child operates computers these days. But to sustain in this computer world one should know how to use a computer rather its background processes. A person who concentrates on such processes obviously becomes a future computer scientist or computer engineer. Even they start their career by knowing how the computer works!

    So you should understand your machine!! For that I advice to download a book called "Windows 7 Dummies" if your OS is windows 7 or "Windows 8 Dummies" if it is Windows 8. Click on below links to download it for free.