Saturday, April 5, 2014

Program in C++ for play-game TIC TAC TOE

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

char square[10] = {'0','1','2','3','4','5','6','7','8','9'};
int testwinner();
void playchart();

int main()
{
    int player = 1,i,choice;
    char mark;
    clrscr();
    do
    {
        playchart();
        player=(player%2)?1:2;
        cout << "Player " << player << ", enter a number ==>  \a ";
        cin >> choice;
        mark=(player == 1) ? 'X' : 'O';
        if (choice == 1 && square[1] == '1')
            square[1] = mark;
        else if (choice == 2 && square[2] == '2')
            square[2] = mark;
        else if (choice == 3 && square[3] == '3')
            square[3] = mark;
        else if (choice == 4 && square[4] == '4')
            square[4] = mark;
        else if (choice == 5 && square[5] == '5')
            square[5] = mark;
        else if (choice == 6 && square[6] == '6')
            square[6] = mark;
        else if (choice == 7 && square[7] == '7')
            square[7] = mark;
        else if (choice == 8 && square[8] == '8')
            square[8] = mark;
        else if (choice == 9 && square[9] == '9')
            square[9] = mark;
        else
        {
            cout<<"Invalid move ";
            player--;
            getch();
        }
        i=testwinner();
        player++;
    }while(i==-1);
    playchart();
    if(i==1)
        cout<<"==>\aPlayer "<<--player<<" win ";
    else
        cout<<"==>\aGame draw";
    getch();
    return 0;
}

int testwinner()
{
    if (square[1] == square[2] && square[2] == square[3])
        return 1;
    else if (square[4] == square[5] && square[5] == square[6])
        return 1;
    else if (square[7] == square[8] && square[8] == square[9])
        return 1;
    else if (square[1] == square[4] && square[4] == square[7])
        return 1;
    else if (square[2] == square[5] && square[5] == square[8])
        return 1;
    else if (square[3] == square[6] && square[6] == square[9])
        return 1;
    else if (square[1] == square[5] && square[5] == square[9])
        return 1;
    else if (square[3] == square[5] && square[5] == square[7])
        return 1;
    else if (square[1] != '1' && square[2] != '2' && square[3] != '3' &&
             square[4] != '4' && square[5] != '5' && square[6] != '6' &&
            square[7] != '7' && square[8] != '8' && square[9] != '9')
        return 0;
    else
        return -1;
}

void playchart()
{
    clrscr();
    cout << "\n\n\tTic Tac Toe\n\n";
    cout << "Player 1 (X)  -  Player 2 (O)" << endl << endl;
    cout << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[1] << "  |  " << square[2] << "  |  " << square[3] << endl;
    cout << "_____|_____|_____" << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[4] << "  |  " << square[5] << "  |  " << square[6] << endl;
    cout << "_____|_____|_____" << endl;
    cout << "     |     |     " << endl;
    cout << "  " << square[7] << "  |  " << square[8] << "  |  " << square[9] << endl;
    cout << "     |     |     " << endl << endl;
}


Click here for more programs on C++

Program in C to sort all words of text in alphabatical order.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<conio.h>
void sort_string(char*);
 int main()
{
   char string[100];
   clrscr();
   printf("Enter some text\n");
   gets(string);

   sort_string(string);
   printf("%s\n", string);
   getch();
   return 0;

}

void sort_string(char *s)
{
   int c, d = 0, length;
   char *pointer, *result, ch;

   length = strlen(s);

   result = (char*)malloc(length+1);

   pointer = s;

   for(ch='a';ch<='z';ch++ )
   {
      for(c=0;c<length;c++ )
      {
         if(*pointer == ch )
         {
            *(result+d) = *pointer;
            d++;
         }
         pointer++;
      }
      pointer = s;
   }
   *(result+d) = '\0';
   strcpy(s, result);
   free(result);
}
Click here for more programs on C++

Friday, April 4, 2014

Software testing -White box testing,Black box testing, Grey box testing

Software testing  :
Software testing is the process to uncover requirement, design and coding errors in the program.

Three most prevalent and commonly used software testing techniques for detecting errors, they are:
1)White box testing,
2)Black box testing and
3)Grey box testing.

1) White Box Testing Technique:
It is the detailed investigation of internal logic and structure of the code. In white box testing it is necessary
for a tester to have full knowledge of source code.

White box testing techniques are:-
i) Control Flow Testing: It is a structural testing strategy that uses the program control flow as a model
control flow and favours more but simpler paths over fewer but complicated path.
ii) Branch Testing: Branch testing has the objective to test every option (true or false) on every control
statement which also includes compound decision.
iii) Basis Path Testing: Basis path testing allows the test case designer to produce a logical complexity
measure of procedural design and then uses this measure as an approach for outlining a basic set of
execution paths.
iv) Data Flow Testing: In this type of testing the control flow graph is annoted with the information about how
the program variables are define and used.
v) Loop Testing: It exclusively focuses on the validity of loop construct.

Advantages:-
a)Side effects are beneficial.
b)It reveals error in hidden code by removing extra lines of code.

Disadvantages:-
a)It is very expensive.
b)Some of the codes omitted in the code could be missed out.





2) Black Box Testing Technique:
It is a technique of testing without having any knowledge of the internal working of the application. It only
examines the fundamental aspects of the system and has no or little relevance with the internal logical structure of the system.

Black box testing techniques are
i) Equivalence Partitioning: It can reduce the number of test cases, as it divides the input data of a software
unit into partition of data from which test cases can be derived.
ii) Boundary Value Analysis: It focuses more on testing at boundaries, or where the extreme boundary values
are chosen. It includes minimum, maximum, just inside/outside boundaries, error values and typical values.
iii) Fuzzing: Fuzz testing is used for finding implementation bugs, using malformed/semi-malformed data
injection in an automated or semi-automated session.
iv) Cause-Effect Graph: It is a testing technique, in which testing begins by creating a graph and establishing
the relation between the effect and its causes. Identity, negation, logic OR
and logic AND are the four basic symbols which expresses the interdependency between cause and effect.
v) Orthogonal Array Testing: OAT can be applied to problems in which the input domain is relatively small,
but too large to accommodate exhaustive testing.
vi) All Pair Testing: In all pair testing technique, test cases are designs to execute all possible discrete
combinations of each pair of input parameters. Its main objective is to have a set of test cases that covers all
the pairs.
vii) State Transition Testing: This type of testing is useful for testing state machine and also for navigation of
graphical user interface.

Advantages:-
a)Efficient for large code segment.
b)Programmer and tester are independent of each other.

Disadvantages:-
a)Inefficient testing.
b)Without clear specification test cases are difficult to design.





3) Grey Box Testing Technique:
 White box + Black box = Grey box, it is a technique to test the application with limited knowledge of the
internal working of an application and also has the knowledge of fundamental aspects of the system
The other name of grey box testing is translucent testing.

Grey box testing techniques are :
i) Orthogonal Array Testing: This type of testing use as subset of all possible combinations.
ii) Matrix Testing: In matrix testing the status report of the project is stated.
iii) Regression Testing: If new changes are made in software, regression testing implies running of test cases.
iv) Pattern Testing: Pattern testing verifies the good application for its architecture and design.

Advantages:-
a)The test is done from the user’s point of view rather than designer’s point of view.
b)Grey box testing provides combined benefits of white box and black box testing techniques

Disadvantages:-
a)Many program paths remain untested.
b)Test coverage is limited as the access to source code is not available.

Thursday, April 3, 2014

PCM - Pulse Code Modulation


PCM :- Pulse Code Modulation
It is the digitization process in which analog signal is represented in digital or discrete form .
It use ordinary analog signal which is digitized at the end office with the help of codec (coder decoder) codec produces 7 or 8 bit numbers .

Codec is inverse of modem -True
It code the digital to analog.
CO  DEC -COder (Analog to Digital) DECoder  (Digital to analog)

PCM is based Nyquest theorem:-
               There are various system for digital transmission:-
1.T1 carrier system (handle 24 voice channel)
2.Encoding system

There are three methods of PCM:
1.Differential pulse code modulation ( DPCM)
2.Delta Modulation
3.Predictive encoding

1.DPCM :-
Definition :It does not transmit actual sample .It transmit difference between current and previous value .Errors can ignored for voice or speech.

2.Delta modulation :
It is special care of DPCM it uses only one bit per sample .Each sample differs from its predecessor by either +1 or -1 .This is called as a sampling interval .
Granular noise :- The schema which is used for slow changing signal which gives distortion called as granular noise.

3.Predictive encoding : this preemptive to DPCM .Some sampling values are used to protect the next value,for this transmitter and receiver must uses same prediction algorithm.


Data  communication
   characteristics :
1. Delivery     :  Correct destination
2. Accuracy  :  Correct data
3. Timeliness  :  Fast enough
4. Jitter          :  Uneven  delay


Data  representation
1Ttext        :  email
2.Numbers :  Direct  conversion
3. Images   :  pixels
4.Audio      : continous
5. Video     :  movie

Data  flow :
1.Simplex
2.Half Duplex
3.Full Duplex

Solve Questions on Computer Science Single choice answers


Multiple Choice Questions ( Single Choice) :-


1) In SQL, which of the following is not a data Manipulation Language Commands?

A) Delete
B) Select
C) Update
D) Create
E)None of the above

Answer :- E)None of the above



2) Which of the following is not a type of SQL statement?

A) Data Manipulation Language (DML)
B) Data Definition Language (DDL)
C)Data Control Language (DCL)
D)Data Communication Language (DCL)
E)None of these

Answer :- D) Data Communication Language



3)Which of the following is not included in DML (Data Manipulation Language)

A)INSERT
B)UPDATE
C) DELETE
D)CREATE
E)None of these

Answer :-D)CREATE



4)TRUNCATE statement in SQL is a -

A) DML statement
B) DDL statement
C) DCL statement
D)DSL statement
E)None of these

Answer:- B) DDL statement



5) In SQL, which command is used to add new rows to a table?

A)Alter Table
B)Add row
C)Insert
D)Append
E)None of the Above

Answer :- C)Insert



6) Stack is also called ____

A) First In First Out (LIFO)
B)Last In First Out (FIFO)
C)First In Last Out (FILO)
D)First Come First Served (FCFS)
E)None of the above

Answer :- C)First In Last Out (FILO)



7)The full form of DDL is

A) Dynamic Data Language
B)Detailed Data Language
C)Data Definition Language
D)Data Derivation Language
E)All of these

Answer :- C)Data Definition Language



8) The OSI model consists of ___layers.

A) Nine
B)Eight
C)Seven
D)Five
E)Eleven

Answer :- C)Seven


9)Assembly language is a _____

A) Low Level Language
B)Middle Level Language
C)High level Language
D)User Language
E)None of these


Answer :- A) Low Level Language


10) Which of the following is a type of translator?

A)Assembler
B)Compiler
C)Interpreter
D)All of the Above
E) None of these

Answer:-  C)  Interpreter



11) Which of the following term is related to the stack?

 A) TOP
 B)PUSH
 C)POP
D)Rear
E) A, B and C.

Answer:-E) A, B and C.


12) In Queues, the end from where items inserted is called

A) Rear
B) Front
C) Top
D) Base
E) None of these

Answer:- A) Rear



13)Which protocol is used for browsing website:

A) TCP
B) FITFP
C)FTP
D)TFTP
E)None of these

Answer:-A) TCP



13) Which of the following is a browser?

A) Netscape Navigator
B) Mosaic
C)Mozilla Firefox
D)Google chrome
E)All of these

Answer:- E)All of these



14) Black Box Testing sometime called -

A) Data flow testing
B) Loop testing
C) Behavioral testing
D)Graph based testing
E)None of these

Answer:-D)Graph based testing



15)The Objective of testing is

A)Debugging
B)To uncover errors
C) To gain modularity
D) To analyze system
E) None of these

Answer :-B) To uncover errors



16)Choose the right sequence of SDLC (Software development life cycle) steps

A) Design, Requirement Analysis, Coding, Testing
B) Requirement Analysis, Design, Coding, Testing
C) Requirement Analysis, Design, Testing, Coding
D) Requirement Analysis, Coding, Design, Testing
E) None of these

Answer :-B) Requirement Analysis, Design, Coding, Testing



17) ODBC is based on ___.

A) Structured Query Language.
B) C language
C) C++ language
D) .net
E)None of these

Answer:- A) Structured Query Language.




18)JVM is a virtual machine that can execute ___
 A)C language
B).net programming
 C)RDBMS
 D)C++ Language
E)Java byte Code

Answer : E) Java byte Code


19)Which of the following virus overtake computer system when it boots and destroy in-formation?

A)Trojan
B)System infectors
C)Boot infectors
D)Stealth virus
E) None of these

Answer :- C) Boot infectors



20)The JDBC-ODBC bridge is

A) Three tiered
B)Multithread
C) Best for any platform
D) All of these
E) None of these

Answer :-B) Multithread



Click here for more questions

Wednesday, April 2, 2014

DTE and DCE

Terms related to modem connectivity:-

DTE :-
Data Terminal Equipment, a device that controls data flowing to or from a computer. The term is most often used in reference to serial communications defined by the RS-232C standard. This standard defines the two ends of the communications channel as being a DTE.
      
              It converts user information into signals or reconverts received signals. These can also be called tail circuits. A DTE device communicates with the data circuit-terminating equipment (DCE). The DTE/DCE classification was introduced by IBM.

           
              A DTE is the functional unit of a data station that serves as a data source or a data sink and provides for the data communication control function to be performed in accordance with the link protocol.

DCE :-
Data Communications Equipment (DCE) device. In practical terms, the DCE is usually a modem and the DTE is the computer itself, or more precisely, the computer's UART chip. For internal modems, the DCE and DTE are part of the same device.


Modem -
A modem (modulator-demodulator) is a device that modulates an analog carrier signal to encode digital information and demodulates the signal to decode the transmitted information
     In modem for Broadband ,
                  ADSL (Asymmetric Digital Subscriber Line) modems, a more recent development,



SQL related terms DCL,DML,DDl,TCL


1)DDL 
 
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples: 
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object


 
2)  DML

Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
SELECT - retrieve data from the a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space for the records remain
MERGE - UPSERT operation (insert or update)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency



 
3)  DCL

Data Control Language (DCL) statements. Some examples:
GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command


 
4)  TCL

Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
COMMIT - save work done
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use


Next

List of bank names in India

 Here is a comprehensive list of banks in India, categorized by type: