CodeTextPro | Free Web Tutorial

CodeTextPro | Free Web Tutorial

Codetextpro Provides free Web tutorial, HTML, CSS, C, C++, Java, JavaScript, PHP, MySql, Python, Program, Programming Notes, Programming Questions and more.



Saturday, August 10, 2019

How Many Types of Constructor are Available in C++? Explain them

11:30 PM 0
How Many Types of Constructor are Available in C++? Explain them

There are mainly three types of constructor available in C++ are the following:

1. Default Constructor - A constructor that accepts no parameter is known as default constructor. If no constructor is defined then the compiler supplies a default constructor. It means that C++ compiler has an implicit constructor which create an object even though it was not defined in the same class.

student :: student(){}
student :: student()

2. Parameterized Constructor - A constructor that receives one or more than arguments/parameter, is called a parameterized constructor.

student :: student(int r, float m)

3. Copy Constructor - A constructor that initializes an object using values of another object passed to it as parameter, is called copy constructor. It creates an alias of the passed object or reference to the passed object.

student :: student(student &t)

What is a Friend Function? Merit and Demerits of Friend Function.

2:08 PM 0
What is a Friend Function? Merit and Demerits of Friend Function.

What is a Friend Function? Merit and Demerits of Friend Function.
What is a Friend Function? Merit and Demerits of Friend Function.

Friend Function - A friend function is not a member function but has the full right access to the private member of the class. The friend keyword is used to make a friend function but the function declaration should be preceded by the keyword friend. The function is defined anywhere in the program like a normal function.


class Sample
int a,b;
void getdata()
friend int total(Sample s);
void Sample::getdata()
int total(Sample s)
int main()
Sample obj;
return 0;


Total =45

Merits of friend function

  1. While defining the friend function, there is no need to use the scope resolution operator as friend keyword.
  2. The friend can be defined anywhere in the program similar to normal function.
  3. It can be invoked like a normal function without the help of any object.
  4. A function may be friend of more than one class. 

Demerits of friend function

  1. The friend function is declared in the class but it, not a member function of class. To access the private data members of class it is necessary to create objects.
  2. When a function is friend of more than one class then forward declaration of class is needed

Difference Between Data Hiding and Data Encapsulation

1:40 PM 0
Difference Between Data Hiding and Data Encapsulation
Difference between data encapsulation and hiding.
The main difference between data hiding and data encapsulation are in the below.

Data Encapsulation
  1. Encapsulation is the process of combining data and function into a single unit called class.
  2. The data in encapsulation is either public or private.
  3. The data is encapsulated using the class keyword.

Data Hiding
  1. Data Hiding is the mechanism where the details of the class are hidden from the outside world.
  2. The data in data hiding is considered as private and non-accessible.
  3. The data hiding is implemented the access specifier. i.e - public, private & protected.

Saturday, August 3, 2019

Dynamic Memory Allocation | Stack Overflow | Dynamic Data Structure

11:05 AM 0
Dynamic Memory Allocation | Stack Overflow | Dynamic Data Structure
stack overflow

What is dynamic memory allocation?
Ans: The process of allocating in runtime is known as dynamic memory allocation. Its function is - malloc, calloc, free, realloc.

what is stack overflow?
Ans: A stack overflow in an undesirable condition in which a particular computer program tries to use more memory space than the call stack overflow.

Why an array is called a static data structure?
Ans: An array could be called static because it is generally not changed structurally once it is created. We do not add, delete or swap the nodes themselves, though we will likely modify the data contained by the nodes that why array is called static data structure.

Why linked list is called dynamic data structure?
Ans: A linked list is called a dynamic data structure because it's size is flexible another way of phrasing that is you don't have to define the maximum number of elements it is supposed to contain when you create it.

What is Searching?(Linear/Sequential Search) - CodeTextPro

9:36 AM 0
What is Searching?(Linear/Sequential Search) - CodeTextPro

What is searching?

Ans: The searching operation is used to search an element in an array.

I/P: An array A[l.......u] of n elements and the key-value.
O/P: Return the index position with a successful message.
DS: An array A[l.......u]

  1. i=0, found=0, location=0 //found=0 indicates search is not finished and unsuccessful.
  2. while(i<=u) and found=0
  3. if(A[i]=key) then
  4. found=1
  5. location=i
  6. else
  7. i=i+1
  8. End if
  9. End while
  10. if found=1 then
  11. Print"Search is successful: Key is present in the array at location"
  12. else
  13. Print"Search is unsuccessful: Key is not present in the array"
  14. End if
  15. Stop.

Friday, August 2, 2019

Linked List in Data Structure - CodeTextPro

10:08 AM 0
Linked List in Data Structure - CodeTextPro

What is a Linked List in Data Structure

A linked list, in symbol terms, is a linear collection of data elements. Those data elements are called nodes. A linked list can be described as a  train or a sequence of nodes, in which is nodes contains one or more data fields and a pointer to the next nodes.

Linked List

Operation of linked list:
There are mainly two types of linked list-
one is insertion(insert) and the other is deletion(delete).

Insertion divided into three-part.

Deletion divided into three-part.

Linked List Insertion:
  1. Insert at the beginning
  2. Insert at the end
  3. Insert at the middle

Linked List Deletion:
  1. Delete at the beginning
  2. Delete at the end
  3. Delete at the middle

Merge Sort - CodeTextPro

12:48 AM 0
Merge Sort - CodeTextPro

Merge sort is a sorting algorithm that uses divide, conquer and combine algorithm technic.

Divide: Divide means partitioning the n- element array to be sorted into two sub-array of n/2 elements. If A is an array containing 0 or 1 element, then it's already sorted. However, if there are more elements in the array divide A* two sub-array. Each containing about half of the elements of A.

Conquer: Conquer means sorting the two sub-array recurshiply using merge sort.

Combine: Combine means merging the two sorted sub-array of size n/2 to produce the sorted array of 'n' elements.

merge sort
Merge Sort

merge sort in c
Merge Sort
Divide and Conquer the array.

merge sort
Merge Sort
Combine the elements from a sorted array.

Saturday, July 27, 2019

Full-Form of LAN, MAN, WAN, TCP, IP, TCP, HTTP, URL, STML, NIC, ISDN, CSMA, OSI and More...

9:35 AM 0
Full-Form of LAN, MAN, WAN, TCP, IP, TCP, HTTP, URL, STML, NIC, ISDN, CSMA, OSI and More...


full form
Networking All Full-Form

LAN = Local Area Network
MAN = Metropolitan Area Network
WAN = Wide Area Network
TCP = Transmission Control Protocol
IP = Internet Protocol
HTTP = Hypertext Transfer Protocol
URL = Uniform Resource Locator
STML = Sort Term Memory Loss
NIC = Network Interface Card
ISDN = Integrated Service Digital Network
CSMA = Carrier Sense Multiple Access
OSI = Open System Interconnection
MAC = Media Access Control
DNS = Domain Name System
FTP = File Transfer Protocol
DHCP = Dynamic Host Configuration Protocol
SMTP = Simple Mail Transfer Protocol
PPP = Point to Point Protocol
ISP = Internet Service Provider
POP = Post Office Protocol
WWW = World Wide Web
STP = Shilded Twisted Pair
UTP = Unshilded Twisted Pair
ISO = Internet Organization for Standardization
POTS = Plain Old Telephone Service
PSTN = Public Switched Telephone Network
UDP = User Datagram Protocol
SAP = Systems Applications and Programs
LLC = Leased Line Connection
PDU = Power Distribution Unit
VAN = Value Added Network
VPAN = Virtual Private Area Network
MTNL = Mahanagar Telephone Nigam Limited
BSNL = Bharat Sanchar Nigam Limited
VSNL = Videsh Sanchar Nigam Limited
ATM = Asynchronous Transfer Mode
OFC = Optical Fibre Cable 
E-mail = Electronic Mail
DSL = Digital Subscriber Line
ADSL = Asymetric Digital Subscriber Line
RAM = Random Access Memory

Friday, July 19, 2019

Multiple Choice Questions on Architecture & Microprocessor - CodeTextPro

10:45 PM 0
Multiple Choice Questions on Architecture & Microprocessor - CodeTextPro

MCQ (Multiple Choice Questions) questions on Architecture & Microprocessor.

(i) Which register can interact with the secondary storage?
(a) MAR
(b) PC
(c) IR
(d) R0

(ii) The decoded instruction is stored in
(a) IR 
(b) PC 
(c) Registers 
(d) MDR

(iii) The fastest data access is provided using

(a) Caches 
(b) DRAM’s 
(c) SRAM’s 
(d) Registers

(iv) ISP stands for
(a) Instruction Set Processor 
(b) Information Standard Processing

(c) Interchange Standard Protocol 
(d) Interrupt Service Procedure

(v) The binary address issued to data or instructions is called as
(a) Physical address 
(b) Location

(c) Relocatable address 
(d) Logical address

(vi) The internal components of the processor are connected by
(a) Processor intra-connectivity circuitry 
(b) Processor bus
(c) Memory bus 
(d) Rambus

(vii) The DMA transfers performed by a control circuit is called
(a) Device interface 
(b) DMA controller
(c) Data controller 
(d) Overlooker

(viii) The number of successful accesses to memory stated as a fraction is called as
(a) Hit rate 
(b) Miss rate
(c) Success rate 
(d) Access rate

(ix) 8085 microprocessor operates at a frequency of
(a) 6 MHz 
(b) 3.2 MHz 
(c) 5 MHz 
(d) 3 MHz

(x) The type of control signal is generated based on
(a) contents of the step counter 
(b) Contents of IR
(c) Contents of condition flags 
(d) All of the above

(xi) READY is used for

(a) Input 
(b) Output 
(c) Both (a) and (b) 
(d) None of these

(xii) Which stack is used in 8085?
(a) FIFO 
(b) LIFO 
(c) FILO 
(d) None of these

(xiii) What is the vector call location of NMI?
(a) 002C H 
(b) 0028 H 
(c) 0010 H 
(d) 0024 H

(xiv) What is a SIM?
(a) Select Interrupt Mask 
(b) Sorting Interrupt Mask
(c) Set Interrupt Mask 
(d) None of these

(xv) RST 7.5 interrupt is
(a) Vectored & Maskable 
(b) Vectored & Non-Maskable
(c) Direct & Maskable 
(d) Direct & Non-Maskable

(xvi) Address line for RST 3 is
(a) 0020H 
(b) 0018H 
(c) 0081H 
(d) None of these

(xvii) If DMA request is sent to the microprocessor with a high signal to the HOLD pin, the microprocessor acknowledges the request
(a) after completing the present cycle 
(b) immediately after receiving the signal
(c) after completing the program 
(d) none of these

(xviii) Which of the following is a user-programmable register?
(a) Memory Address Register 
(b) Accumulator
(c) Program Counter 
(d) All of these

(xix) Select the invalid instruction
(a) MOV M, A 
(b) ADI 67 
(c) LDAX B 
(d) STAX H

(xx) The interrupt line having the highest priority is
(a) RST 7.5 
(b) READY 
(c) TRAP 
(d) INTR

(xxi) The address line required for 16 KB memory chip is
(a) 13 
(b) 14 
(c) 15 
(d) 16

(xxii) A hard disk with 20 surfaces will have _____ heads.
(a) 10 
(b) 5 
(c) 1 
(d) 20

(xxiii) Which among the following is Volatile?

(a) ROM 
(b) EPROM 
(c) DROM 
(d) RAM

(xxiv) Where the result of arithmetic and logical operation are stored?
(a) In Accumulator 
(b) In Cache Memory
(c) In ROM 
(d) In Instruction Registry

(xxv) Which determines the address of I/O interface?
(a) Register select 
(b) Chip select

(c) Both of the above 
(d) None of the above

Wednesday, July 17, 2019

What Is Wi-Fi / WiFi? Definition From CodeTextPro

3:12 PM 0
What Is Wi-Fi / WiFi? Definition From CodeTextPro
What is Wi-Fi?
Wi-Fi is a facility which is allowing laptop, computers, smartphones, tablet or many other devices to connect to the Internet or communicate with one another wirelessly within a particular distance.

Wi-Fi or WiFi is a technology for wireless local area networking with devices based on the IEEE 802.11 standards. 802.11 is the "radio frequency" needed to transmit Wi-Fi. Devices that can use Wi-Fi technology include personal
computers, video-game consoles, smartphones, digital cameras, tablet computers, digital audio players and modern printers. Wi-Fi compatible
devices can connect to the Internet via a WLAN network and a wireless access point. Such an access point (or hotspot) has a range of about 20
meters (66 feet) indoors and a greater range outdoors. Hotspot coverage can be as small as a single room with walls that block radio waves, or as large as many square kilometers achieved by using multiple overlapping access points.

wi-fi router

Wi-Fi most commonly uses the 2.4 gigahertz Ultra-High Frequency(UHF) and 5 gigahertz Super High Frequency (SHF) ISM radio bands. Having no physical connections, it is more vulnerable to attack than wired connections, such as Ethernet.

To connect to a Wi-Fi LAN, a computer has to be equipped with a Wireless Network Interface Controller (WNIC). The combination of a computer and interface controller is called a station. For all stations that share a single radio frequency communication channel, transmissions on this channel are received by all stations within range. The transmission is not guaranteed to be delivered

and is, therefore, a best-effort delivery mechanism.


An 802.11 WNIC can operate in two modes known as infrastructure mode and ad hoc mode:

Infrastructure mode :
In an infrastructure mode network, the WNIC needs a wireless access point: all data is transferred using the access point as the central hub. All wireless nodes in an infrastructure mode network connection to an access point. All nodes connecting to the access point must have the same service set identifier (SSID) as the access point, and if a kind of wireless security is enabled on the access point they must share the same keys or other authentication parameters.

Ad hoc mode :
In an ad hoc mode network the WNIC does not require an access point but rather can interface with all other wireless nodes directly. All the nodes in an ad hoc network must have the same channel and SSID.

Routers that incorporate a digital subscriber line modem or a cable modem and a Wi-Fi access point, often set up in homes and other buildings, provide Internet access and internetworking to all devices connected to them, wirelessly or via cable.



Similarly, battery-powered routers may include a cellular Internet radio modem and Wi-Fi access point. When subscribed to a cellular data carrier, they allow nearby Wi-Fi stations to access the Internet over 2G, 3G, or 4G networks using the tethering (phone-as-modem) technique. Many smartphones have a built-in capability of this sort, including those based on Android, BlackBerry, iOS (iPhone) and Windows Phone.

Wireless range-extenders or wireless repeaters can extend the range of an existing wireless network. Strategically placed range-extenders can elongate a signal area or allow for the signal area to reach around barriers such as those pertaining in L-shaped corridors.


wi-fi router

An access point compliant with either 802.11b or 802.11g, using the stock antenna might have a range of 100m (330ft). The same radio with an external semi parabolic antenna (15dB gain) might have a range over 20 miles.

Tuesday, July 16, 2019

File Handling in C || CodeTextPro

1:13 PM 0
File Handling in C || CodeTextPro

File Handling in C Programming

A file represents a sequence of bytes on the disk where a group of related data is stored. The file is created for permanent storage of data. It is a ready-made structure.

In C language, we use a structure pointer of the file type to declare a file.

FILE *fp;

C provides a number of functions that helps to perform basic file operations. Following are the functions,

file handling in c

Opening a File or Creating a File

fp= fopen( file_name, file_mode)

file handling in c

Input/Output operation on File

In the above table, we have discussed about various file I/O functions to perform reading and writing on file.
getc() and putc() are simplest functions used to read and write individual characters to a file.

FILE *fp;
char ch;
fp = fopen("one.txt", "w");
printf("Enter data");
while( (ch = getchar()) != '$') {
fp = fopen("one.txt", "r");
while( (ch = getc(fp)! = EOF)

Note: This program will read the input character-wise from the user until a '$' is pressed. Then display the contents of the file in the console.

File Handling in C Programming

Reading and Writing from File using fwrite() and fread()

** C program to write all the members of an array of structures to a file using fwrite(). Read the array

from the file and display on the screen.

#include <stdio.h>
struct student
char name[50];
int height;
int main(){
struct student stud1[5], stud2[5];
FILE *fptr;
int i;
fptr = fopen("file.txt","wb");
for(i = 0; i < 5; ++i)
printf("Enter name: ");
printf("Enter height: ");
scanf("%d", &stud1[i].height);
fwrite(stud1, sizeof(stud1), 1, fptr);
fptr = fopen("file.txt", "rb");
fread(stud2, sizeof(stud2), 1, fptr);
for(i = 0; i < 5; ++i)
printf("Name: %s\nHeight: %d", stud2[i].name, stud2[i].height);


If you want to download file handling in c pdf file clicks the link below.

File Handling in C PDF

Memory Management in OS || Memory Management Techniques in OS

8:52 AM 0
Memory Management in OS || Memory Management Techniques in OS
Memory Management

In a mono programming or uni programming system, the main memory is divided into two parts, one part for the operating system and another part for a job which is currently executing. Consider the following figure below.

memory management
memory management in operating system notes

Partition-1 is allowed for Operating system and partition-2 is allowed for the user process. But some part of partition 2 wasted, it is indicated by black color.

In a multiprogramming environment, the user space is divide into the number of the partition. Each partition is for one process.

The task of the subdivision is carried out dynamically by the operating system, this task is known as “Memory Management”.

Memory Management Unit (MMU):

It is a hardware component that handles all memory and caching operation associated with the processor. So MMU is responsible for all overactivity of memory management.

Logical Address Space and Physical Address Space:
An address generated by CPU is called logical address, whereas an address generated by MMU is called Physical address.

For example, J1 is a program, written by the user, the size of the program is 100KB. But program loaded in main memory from 2100 to 2200 KB. This actual loaded address in main memory is called physical address.

The set of all logical address is generated by a program is referred to as a “Logical address space”.

The set of the physical address corresponding these logical address referred to as a “Physical address space”.

Logical and Physical address space in OS

In our example from 0 to 100KB is the logical address space and from 2100 to 2200KB in the physical address space.

So, Physical address space = Logical address space + Contents of relocation register/ Base value
2200= 100 + 2100

The run-time mapping from logical to physical address is done by the memory management unit (MMU). The relocation register is also known as the base register. The value of the relocation register is added to every address generated by a user process at the time it is sent to the memory.

For example, the base is at 2100, then the attempt by the user to address location 0 is dynamically related to location 2100. An access location 100 is mapped to location 2200.


A process needs to be in memory for execution. But sometimes there is not enough main memory to hold all the currently active processes in a timesharing system. So, the excess process is kept on disk and brought in to run dynamically. Swapping is the process of bringing in each process in main memory, running it for a while and then putting it back to the disk.

Swap in- switch a process from disk to main memory.

Swap out- switch a process from main memory to disk.

Memory Allocation:

Memory allocation is a process by which computer programs are assigned memory or space. It is of three types:

1. First Fit
The first hole that is big enough is allocated to the program.

2. Best Fit
The smallest hole that is big enough is allocated to the program.

3. Worst Fit
The largest hole that is big enough is allocated to the program.

Memory Partitioning:

1. Fixed Partitioning: Main memory is divided into a no. of static partitions at system generation time. A process may be loaded into a partition of equal or greater size. Memory Manager will allocate a region to a process that best fits it unused memory within an allocated partition called internal fragmentation Advantages: Simple to implement Little OS overhead Disadvantages: Inefficient use of Memory due to internal fragmentation. Main memory utilization is extremely inefficient. Any program, no matter how small, occupies an entire partition. This phenomenon, in which there is wasted space internal to a partition due to the fact that the block of data loaded is smaller than the partition, is referred to as internal fragmentation.

Two possibilities of Partitioning:
a). Equal size partitioning 
b). Unequal size Partitioning

Unequal size partitioning is not suitable for systems in which process memory requirements not known ahead of time; i.e. timesharing systems.

Fixed Memory Partition

When the queue for a large partition is empty but the queue for a small partition is full, as is the case for partitions 1 and 3. Here small jobs have to wait to get into memory, even though plenty of memory is free An alternative organization is to maintain a single queue as in above Fig. (b).
Whenever a partition becomes free, the job closest to the front of the queue that fits in it could be loaded into the empty partition and run.