User talk:Vishal232

DO YOU KNOW WHAT COMPUTER STANDS FOR?

COMMON OPERATING MACHINE PARTICULAR USER TRADING & EDUCATIONAL RESEARCH.

DO YOU KNOW WHO IS KNOWN AS FATHER OF COMPUTER?

CHARLES BABBAGE.

HAVE YOU EVER HEARD OF ENIAC? IT WAS THE FIRST ELECTRONIC COMPUTER DEVELOPED IN 1946 AT USA. ENIAC STANDS FOR ELECTRONIC NUMERATOR INTEGRATOR AND CALCULATOR.

Always Remember!!! Group of 8 Bits =1 byte 4 Bits=a Nibble

1KB(Kilo-Byte)=1024 Bytes. 1KB(Mega-Byte)=1024 KB. 1GB(Giga-Byte)=1024 MB. 1TB(Tera-Byte)=1024 GB. 1PB(Peta-Byte)=1024 TB.

MOVING RIGHT ALONG.

--- Programming in C++

GETTING STARTED WITH C++

SOFTWARE: Turbo C++ version 3

It is a very complicated software. The c++ programming language was developed at AT & T Bell Laboratories in early 1980s by Bjarne Stroustrup. He found lacking for simulations & decided to extend the language by adding features from his favourite language , simula 67.

C++ provides followin Tokens (smallest) individual unit in a program. Keywords Identifiers Literals Punctuators Operators

C++ allows users the following literals:- integer - constant (Decimal,Octal,Hexa-decimal) character-constant Floating-constant String-literal

// my first C++ program All lines starting with // are comments. Compiler does not executes comments.

Statement that begin with #(hash/pound) sign are directives for the preprocessor.
 * 1) include

These statements are processed before compilation takes place.

The #include statement tells the compiler preprocessor to include the header file iostream (notice the header file iostream.h) in the program.

int main Beginning of the main function. The main function is the point by where all C++ programs begin with their execution. In fact, the content of main is always the first to be executed when a program starts. It is essential that all C++ programs have a main function.

return 0; The return instruction makes the main to finish and it is returning a zero(0). Returning 0 is the most usual way of telling that program has been terminated normally i.e.,it has not found any errors during its execution.

Predefined Streams in I/O Library:

1.Cin(pronounced-"see-out"),as istream class object tied to standard input. cin stands for console input.

2.Cout(pronounced-"see-out"),an ostream class object tied to standard output. Cout stands for console output.

3.Cerr(pronounced-"see-err"),as ostream class object tied to standard error. Cerr stands for console error.

"\n" represents the new line character.

Output operator"<<" ("put to") Strean insertion operator -used to direct a value to standard output. for instance, cout<<"The sum of 2+5="; cout<<2+5;

Input operator ">>" ("get from") streams extraction operator- used to read a value from standard input.

variable: Refers to a storage area whose contents can vary during processing.

Generally, a program in C++ includes a header file iostream.h for standard stream input/output facilities.

Every C++ program must contain a function named main.The program execution begins atmain.

Every executable statement in C++ must be terminated by a semi colon.

The multiple use of input or output operators(">>" or "<<") in a statement is called Cascading of I/O operators.

A C++ program files should have a proper file extention depending upon the implementation ofC++,e.g. .C,.CC,.CPP,..CXX,etc.

Turbo C++ and Borland C++ use .cpp for c++ program. Zortech C++ uses extention .cxx and UNIX AT & T versions use .c and .cc extentions.

In Turbo C++ you are trying to chain more than 70 variables through a single statement, it produces following error.:- Out of memory.

= is used for assingnment == is used for equals to

There are 3 types of looping:

1.While loop:                        syntax-while(expression)

2.For loop: A for loop may contain multiple initiation &/or multiple update expressions. These multiple expressions must be seperated by commas.

3.Do-while loop:

do { statement; } while(test-expression);

Array: Collection of variables of the same type that are referred by a common name.

Function: A function is a subprogram that acts on data and often returns a value.

Switch : C++ provides a multiple-Branch selection statement known as switch.

Algorithm : An algorithm is a logical sequence of discrete steps that describe a complete solution to a given problem in a finite amount of time.

BYTES CONSUMING:

TYPE Bytes Integer  - 2 Float      -   4 Char     -  1

Header Files:

stdio.h   Standard I/O Package [getc,getchar,putc,putchar,etc.]

string.h String manipulations.

math.h   [cos,log,sin,tan,etc.]

stdlib.h [search/sort routines]

iostream.h Basic C++ streams I/O routines: [get,open,close,put,read,ignore,bad,fail,good,clear]

iomanip.h I/O manipulators: [endl,hex,oct,setfile,setw]

Header files provide function prototypes,definitions for library functions.

ERRORS:

Mostly, the user is responsible for error birth.

Types of ERRORS:

Mostly, the user is reponsible for error birth.

Compile-time errors: 1.Syntax-error: It occurs when grammatical rule of C++ is violated. 2.Semantics errors: It occurs when statements are not so meaningful.

Run-time error: It occurs when their is infinite looping or wrong value is input.

A program should be robust so as to recover and continue following an error.

Those errors which may contain an incorrectly implemented algorithm,or use of a variable before its initialization,or unmarked end of a loop. These must be handled carefully.

Games:

Mainly, a computer game has 5 (five) elements:

Graphics Sound Interface Gameplay & Story. WRITING A SIMPLE GAME IN C++:

1. HIGH/LOW NO. GUESSING GAME: Guess a no. b/w 0-100.You have 7 chances to guess a no. It is a good logic game in which computer chooses a no. and you have to find the no. to win.

2.Hangman(a word guessing game) Guess a letter. Computer will pick a word & you must try to guess the letter in the word. If you guess the word with less than 8 mistakes,then you win.

3.Cross 'N' Naughts (Tic-Tac-Toe) Game: You can either play this game with another user or with computer. First, you have to choose one cell (which is marked for you),then after that chance will be given to other player (computer or second player) to choose an unmarked cell. A person wins,if he covers any one of the entire row or entire diagonal cells. If none of the players wins & if all cells are covered then the game is a draw.

4.Cows n Bulls Game: Cows & Bulls is also a word guessing game .In this game computer randomly picks a word which you have to guess.If you guess the right word ,you are winner. However, if your word does not matches the computer's word then the computer will give you hints in terms of Cows and Bulls.


 * A Cow refers to an incorrect letter at correct position.
 * A Bull refers to correct letter at correct position.

These four games are made by myself. If anybody wants these games he/she can send me request to the sender signed.

Play the game and enjoy!!!!