Вы находитесь на странице: 1из 6

#define preprocessor directive The #define preprocessor allows to define symbolic names and constants e.g. #define pi 3.

14159 This statement will translate every occurrence of PI in the program to 3.14159 The following are the basic concepts used in object-oriented programming. Object-: An object is an identifiable entity with some characteristics and behavior. Class-: A class represents a group of objects that share common properties, behavior and relationships. Data Abstraction-: Abstraction refers to act of representing essential features without including the background details or explanations. Encapsulation-: The wrapping up of data and associated functions into a single unit is known as ENCAPSULATION. Encapsulation implements data abstraction. Data Hiding: Data hiding is a property of OOPS by which the crucial data of an object is made hidden from the rest of the program or outside world. In C++ data hiding is provided by using access specifiers Private & Protected. Inheritance-: It is the capability of one class of things to inherit capabilities or properties from another class. Base Class: It is the class whose properties are inherited by another class. It is also called Super Class. Derived Class: It is the class that inherit properties from base class(es).It is also called Sub Class. Polymorphism-: It is the ability for a message or data to be processed in more than one form. Polymorphism is a property by which the same message can be sent to objects of several different classes. Polymorphism is implemented in C++ through virtual functions and function overloading. Parameters (or Arguments) and their types: Parameters are the values passed to a function for its working. There are two types of parameters: 1. Actual parameters: Parameters that appears in the calling statement of the function are known as actual parameters. 2. Formal Parameters: Parameters that appears in the function definition are known as formal parameters. A class groups its members into three sections : private, protected, and public. private members of a class are accessible only from within other members of the same class or from their FRIENDS. protected members are accessible from members of their same class and from their friends, but also from members of their derived classes. public members are accessible from anywhere where the object is visible. CONSTRUCTOR It is a member function having same name as its class and which is used to initialize the objects of that class type with a legal initial value. Constructor is automatically called when object is created. Types of Constructor Default Constructor-: A constructor that accepts no parameters is known as default constructor. student :: student() { rollno=0; } Parameterized Constructor -: A constructor that receives arguments/parameters, is called parameterized constructor. student :: student(int r) { rollno=r; }

Copy Constructor-: A constructor that initializes an object using values of another object passed to it as parameter is called copy constructor. It creates the copy of the passed object. student :: student(student &s) { rollno = s.rollno; } There can be multiple constructors of the same class, provided they have different signatures.This feature is called constructor overloading. DESTRUCTOR A destructor is a member function having sane name as that of its class preceded by ~(tilde) sign and which is used to destroy the objects that have been created by a constructor. It gets invoked when an objects scope is over. ~student() { } Question : What is run-time error, logical error and syntax error? Answer : Syntax error - the errors which are traced by the compiler during compilation, due to wrong grammar for the language used in the program, are called syntax errors. For example, cin>>a; // instead of extraction operator insertion operator is used. Run time Error - The errors encountered during execution of the program, due to unexpected input or output are called run-time error. For example - a=n/0; // division by zero Logical Error - These errors are encountered when the program does not give the desired output, due to wrong logic of the program. For example : remainder = a+b // instead of using % operator + operator is used. Question : What is the role of #include directive in C++? Answer : The preprocessor directive #include tells the complier to insert another file into your source file. In effect, #include directive is replaced by the contents of the file indicated. Question : What is the difference between call by value and call by reference in a user defined function in C++? Answer : The value of the actual parameters in the calling function do not get affected when the arguments are passed using call by value method, since actual and formal parameters have different memory locations. The values of the formal parameters affect the values of actual parameters in the calling function, when the arguments are passed using call by reference method. This happens since the formal parameters are not allocated any memory, but they refer to the memory locations of their corresponding actual parameters Question : What is the difference between local variable and global variable? Answer : Local variables are those variables which are declared within a function or a compound statement and these variables can only be used within that function/scope. They cannot be accessed from outside the function or a scope of its declaration. This means that we can have variables with the same names in different functions/scope. Local variables are local to the function/scope in which they are declared. Global variables are those variables which are declared in the beginning of the program. They are not declared within a function. So, these variables can be accessed by any function of the program. So, global variables are global to all the functions of the program. Default values in parameters: When declaring a function we can specify a default value for each of the last parameters. This value will be used if the corresponding argument is left blank when calling to the function. #include <iostream> using namespace std;

int divide (int a, int b=2) { int r; r=a/b; return (r); } int main () { cout << divide (12); cout << endl; cout << divide (20,4); return 0; } Character Functions: Header File : ctype.h Function Description isalnum( ) Returns nonzero if a character is alphanumeric isalpha( ) Returns nonzero if a character is alphabetic isdigit( ) Returns nonzero if a character is a digit islower( ) Returns nonzero if a character is lowercase isupper( ) Returns nonzero if a character is an uppercase character tolower( ) Converts a character to lowercase toupper( ) Converts a character to uppercase String Functions : Header File : string.h strcat concatenates two strings strcmpi compares two strings (Case insensitive comparison) strcmp compares two strings (Case sensitive comparison) strcpy copies (overwrite) one string to another strlen returns the length of a given string Input / Output Manipulation Functions : Header File : iomanip.h setf Sets ios flags. setw Sets the width of the field assigned for output. Setprecision Sets the total number of digits to be displayed when floating point numbers are to be displayed. Mathematical Functions : Header File : math.h pow Returns base raised to the power passed as first & second argument respectively.. exp Returns natural logarith e raised to the power passed as argument. fabs Returns absolute value of the number passed as argument. ceil Returns smallest integer not less than the real number passed as argument. floor Returns largest integer not greater than the real number passed as argument. Some more header files and their associated functions randomize( ) and random sqrt Returns square root of the number passed as argument. Other functions of math.h: Trigonometrical functions: acos, asin, atan, sinh, cosh, tanh etc Exponential functions: exp, frexp etc Logarithmic functions: log, logio etc. stdio.h getc getchar gets putc putchar puts gets fstream.h

open close get getline read write put seekg seekp tellg tellp eof stdlib.h rand srand random randomize malloc randomize( ) initializes the random number generator with a randomize( ) initializes the random number generator with a random number. Working of random ( ) function Syntax : random(num) random ( num) generates random numbers within the range 0 to (num-1). For example random(6) generates random numbers between 0 to 6. Example: In the following program, if the value of N given by the user is 20, what maximum and minimum value the program could possibly display? #include<iostream.h> #include<stdlib.h> void main() { int N, Guessme; randomize(); cin>>N; Guessme = random(N-10) + 10; cout<<Guessme<<endl; } [Note : here random (10) will generates random numbers between 0 to 10-1 ( 0 to 9)] Minimum value : 10 Maximum value : 19 COLUMN MAJOR FORMULA LOC (A[I][J]) = BASE(A) + W*[R*J + I] Switching Techniques: 1. Circuit Switching: In the Circuit Switching technique, first, the complete end-to-end transmission path between the source and the destination computers is established and then the message is transmitted through the path. The main advantage of this technique is guaranteed delivery of the message. Mostly used for voice communication. 2. Message Switching: In the Message switching technique, no physical path is established between sender and receiver in advance. This technique follows the store and forward mechanism. 3. Packet Switching: In this switching technique fixed size of packet can be transmitted across the network. Transmission media: 1. Twisted pair cable: - It consists of two identical 1 mm thick copper wires insulated and twisted together. The twisted pair cables are twisted in order to reduce crosstalk and electromagnetic induction. Advantages: (i) It is easy to install and maintain. (ii) It is very inexpensive Disadvantages: (i) It is incapable to carry a signal over long distances without the use of repeaters. (ii) Due to low bandwidth, these are unsuitable for broadband applications. 2. Co-axial Cables: It consists of a solid wire core surrounded by one or more foil or braided wire shields, each separated from the other by some kind of plastic insulator. It is mostly used in the cable wires. Advantages: (i) Data transmission rate is better than twisted pair cables.

(ii) It provides a cheap means of transporting multi-channel television signals around metropolitan areas. Disadvantages: (i) Expensive than twisted pair cables. (ii) Difficult to manage and reconfigure. 3. Optical fiber: - An optical fiber consists of thin glass fibers that can carry information in the form of visible light. Advantages: (i) Transmit data over long distance with high security. (ii) Data transmission speed is high (iii) Provide better noise immunity (iv) Bandwidth is up to 10 Gbps. Disadvantages: (i) Expensive as compared to other guided media. (ii) Need special care while installation Network devices: Modem: A MODEM (MOdulator DEModulator) is an electronic device that enables a computer to transmit data over telephone lines. There are two types of modems, namely, internal modem and external modem. Hub: A hub is a hardware device used to connect several computers together. Switch: A switch (switching hub) is a network device which is used to interconnect computers or devices on a network. It filters and forwards data packets across a network. The main difference between hub and switch is that hub replicates what it receives on one port onto all the other ports while switch keeps a record of the MAC addresses of the devices attached to it. Gateway: A gateway is a device that connects dissimilar networks. Repeater: A repeater is a network device that amplifies and restores signals for long distance transmission. The BUS Topology: - The bus topology uses a common single cable to connect all the workstations. Each computer performs its task of sending messages without the help of the central server. However, only one workstation can transmit a message at a particular time in the bus topology. Advantages: (i) Easy to connect and install. (ii) Involves a low cost of installation time. (iii) Can be easily extended. Disadvantages:(i) The entire network shuts down if there is a failure in the central cable. (ii) Only a single message can travel at a particular time. (iii) Difficult to troubleshoot an error. The STAR Topology: - A STAR topology is based on a central node which acts as a hub. A STAR topology is common in homes networks where all the computers connect to the single central computer using it as a hub. Advantages: (i) Easy to troubleshoot (ii) A single node failure does not affect the entire network. (iii) Fault detection and removal of faulty parts is easier. (iv) In case a workstation fails, the network is not affected. Disadvantages:(i) Difficult to expand. (ii) Longer cable is required. (iii) The cost of the hub and the longer cables makes it expensive over others.

(iv) In case hub fails, the entire network fails. The TREE Topology: - The tree topology combines the characteristics of the linear bus and the star topologies. It consists of groups of star configured workstations connected to a bus backbone cable. Advantages: (i) Eliminates network congestion. (ii) The network can be easily extended. (iii) Faulty nodes can easily be isolated from the rest of the network. Disadvantages: (i) Uses large cable length. (ii) Requires a large amount of hardware components and hence is expensive. (iii) Installation and reconfiguration is very difficult. Types of Networks: LAN (Local Area Network): A Local Area Network (LAN) is a network that is confined to a relatively small area. It is generally limited to a geographic area such as writing lab, school or building. It is generally privately owned networks over a distance not more than 5 Km. MAN (Metropolitan Area Network): MAN is the networks cover a group of nearby corporate offices or a city and might be either private or public. WAN (Wide Area Network): These are the networks spread over large distances, say across countries or even continents through cabling or satellite uplinks are called WAN. PAN (Personal Area Network): A Personal Area Network is computer network organized around an individual person. It generally covers a range of less than 10 meters. Personal Area Networks can be constructed with cables or wirelessly. TCP/IP (Transmission Control Protocol / Internet Protocol)

System for Mobile Communications) cket Radio Service)

Wi-Fi (Wireless Fidelity) s for the first generation of wireless analog cellular. communication. 3 G: Some of the advantages of 3 G are:(i) Broadband capabilities, greater power and capacity. (ii) Higher data rate at lower cost than 2G. (iii) High speed data transmission (iv) Global roaming, wider coverage. Web Scripting: - The process of creating and embedding scripts in a web page is known as Web Scripting. Types of Scripts:(i) Client Side Scripts: - Client side scripts supports interaction within a webpage. E.g. VB Script, Java Script, PHP (PHPS Hypertext Preprocessor). (ii) Server Side Scripts: - Server side scripting supports execution at server end. E.g. ASP, JSP, PHP