Tuesday, September 25, 2012

SELECTION SORT IN C++

#include <iostream>

void selectionSort(int AR[],int size)
{
     int i,j,temp;
     for (i=0; i<size; i++)
     {
          for (j=i+1; j<=size; j++)
          {
               if ( AR[i] > AR[j] )
// sorts in ascending order
               {
                    temp = AR[j];
                    AR[j] = AR[i];
                    AR[i] = temp;
               }
          }

     }


}


int main()
{
     int arr[20],size;
    
// prompts the user to enter the elements in the array
     cout<<" Enter the no. of elements that you want to enter (max 20 ) : ";
     cin>>size;
     cout<<" Now enter the elements in the array ";
     for (int i=0; i<size; i++)
     {
          cout<<" \n Element "<<i<<" : ";
          cin>>arr[i];
     }
     selectionSort(arr,size);
// calls the function to sort the array
     cout<<" \n The sorted array is as follows ";
     for (int i=0; i<size; i++)
     {
          std::cout<<" \n Element "<<i<<" : "<<arr[i];
     }
     return 0;
}






Friday, September 21, 2012

Simple CPP Game Applications for finding a number

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
/*
This program plays a simple game.The computer picks a random number
from
0 to 100, and the user tries to guess the number.
*/
const int totchan=7;
void main()
{
 int number;        //the computer's random number
 int guess;         //the user's guess
//chanscor stores score for 1successful chance.
int chances=0,score=0,chanscor;       
char ans;
 do
 { clrscr();
   chances=score=0;
   cout<<"\nWelcome to the High/Low game.";
   cout<<"I will pick a random number from 0 to 100."<<endl;
   cout<<"You must try to guess the number."<<endl;
   randomize();
   number=(int)(rand()%100);
   chanscor=100/totchan;        //score for each successful chance
   do
   {
     cout<<"What is your guess? (0 to 100) "<<endl;
     cin>>guess;
     if((guess<0)||(guess>100))
     {
    cout<<"Sorry, but your guess "<<guess<<"must be from 0 to 100."<<endl;
     }
     else if(guess < number)
     {
    cout<<guess<<" is low.Try a higher number."<<endl;
     }
     else if(guess > number)
     {
    cout<<guess<<" is high.Try a lower number."<<endl;
     }
     else       
     {   
                      //if correct number is guessed
        //number is correct, and the "do" loop will end below
    cout<<guess<<" is correct. Congratulations!"<<endl;
    score=chanscor*(totchan-chances);   //score calculated for number ofchances left
    cout<<"Your score is "<<score<<endl;
        break;
     }
     chances++;
     if(guess!=number)
     cout<<"Now you have "<<totchan-chances<<"chances left."<<endl;
     if(chances==totchan)
     { cout<<"Only "<<totchan<<"chances are allowed.Better luck nexttime";
       cout<<"The actual number was "<<number<<endl;
       break;
     }
     }while (guess!=number);
     cout<<"Thank you for playing High/Low!"<<endl;
     cout<<"Want to play it again? (y/n)..."<<endl;
     cin>>ans;
   }while(ans=='y' || ans=='Y');
 }


Sample Output :
Welcome to the High/Low game.I will pick a random number from 0 to 100.
You must try to guess the number.
What is your guess? (0 to 100)
56
56 is high.Try a lower number.
Now you have 6chances left.
What is your guess? (0 to 100)
28
28 is low.Try a higher number.
Now you have 5chances left.
What is your guess? (0 to 100)
36
36 is low.Try a higher number.
Now you have 4chances left.
What is your guess? (0 to 100)
46
46 is high.Try a lower number.
Now you have 3chances left.
What is your guess? (0 to 100)
40
40 is correct. Congratulations!
Your score is 42
Thank you for playing High/Low!
Want to play it again? (y/n)...

Friday, September 14, 2012

ESSENTIAL SYLLABUS OF CSE/IT/ECE FOR PLACEMENT

Compulsory Modules (all 3)
     1. English Comprehension
     2. Quantitative Ability
   3. Reasoning and Logical Ability
 Optional Modules (1 or more)
     1. Computer Programming Principles and Application
     2. Computer Fundamentals
     3. Electronics and Semiconductor
1.     English Comprehension

  Synonyms/Antonyms/Word Meaning (Vocabulary)
  Complete the Sentence (Grammar)
  Spot error/Correct sentence (Grammar/sentence construction)
  Sentence Ordering (Comprehension skills)
  Questions based on passage (Comprehension skills)

2.     Quantitative Ability

  Basic Math Understanding and Algebra: Decimals, fractions, powers,   HCF, LCM,   Solving equations, etc.
  Word Problems
  Understanding of Logarithms and exponents
Permutation and Combination, Probability

3.     Reasoning and Logical Ability

  Analogical Reasoning: Analogy and Classification questions
  Deductive Logic: Statement-Conclusion, Statement-Assumption, Data-sufficiency type, Syllogisms, etc.
  Pattern Recognition: Coding and Decoding Questions, Alphabet Test
  Composition of Complex relations: Blood Relation, Direction  Understanding, Logical Word Sequence
  Reasoning Puzzles, Theme Detection




1.     Computer Programming Principles and Application 

This test is based on no particular programming language. The test is completely language independent and tests the programming and algorithm development concepts of the candidate.
The topics include:


       1. Structure and constructs of Computer Programs 
  Programming flow, Procedures, Functions and Arguments, Methods
  Data-types, how data is stored in computers, input/output, manipulation, methods of referencing and assessing data (including pointers).
  Iteration, decision-making, recursions
  Algorithm Complexity: Space and time Complexity, Asymptotic Notation
  Compilation, Linking and Execution; debugging, kinds of errors.
      2. Data-structures and Basics Algorithms 
  Data Storage Methods: Linked lists, Arrays, Queues, Stacks, Trees, Heaps, Hash tables, graphs; Stress on which data structure to use for a given application
  Data retrieval, Insertion of new data, merging of data from two data structures
  Data search and sorting, Methods of array sorting and trade-off
      3. Object Oriented Programming Concepts 
  Classes, objects and methods
  Data Encapsulation, Data hiding, Inheritance
  Polymorphism, Overloading, Abstraction

2.     Computer Fundamentals 
  Basic Hardware Usage, Maintenance and Organization
  Operating System Usage
  Basic Software and Internet
3.     Electronics and Semiconductor

  Basics only

Monday, September 10, 2012

HOW TO CONNECT TO MS ACCESS IN VB.NET



Dim conn As New OleDb.OleDbConnection
         conn.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Love.mdb"
        Try
             conn.Open()

        Catch ex As Exception
            MessageBox.Show(ex.Message, "connection to access failed")

        End Try
 Dim comm As New OleDb.OleDbCommand

  comm.CommandText = "delete from customer where ID = " & TextBox1.Text

         comm.Connection = conn

        If  comm.ExecuteNonQuery() = 1 Then
            MessageBox.Show("Successful")
        End If


         comm.CommandText = "select ID from customer where contact = '" & TextBox3.Text & "'"
         comm.Connection = conn

        Dim dr As OleDb.OleDbDataReader =  comm.ExecuteReader()

        If dr.HasRows Then
            Do While dr.Read()
                MessageBox.Show("The Customer id is " & dr("ID"))
            Loop

        End If


       conn.Close()

GENERATION OF LARGEST PALINDROME MADE BY MULTIPLICATION OF 3 DIGIT NUMBER



import java.io.*;
import java.lang.*;

public class Abcd {

    public static void main(String[] args) {
        int value = 0;
        for(int i = 100;i <=999;i++)
        {
            for(int j = i;j <=999;j++)
            {
                int value1 = i * j;

String s = new Integer(value1).toString();

String r = new StringBuffer(s).reverse().toString();
      
if(s.equals(r) && value<value1) {
                    value = value1;

                }

            }
        }

        System.out.println(value);
    }
}