Showing posts with label Interview Question. Show all posts
Showing posts with label Interview Question. Show all posts

Define types of Network?



What are the types of Computer Network?


A computer network is the interconnection of various computers located at different places. There are different types of network based on their size(Number of devices), data transfer speed and their reach. There are three main category of networks given below:-

  • LAN
  • MAN
  • WAN



LAN:-


LAN stands for Local Area Network. It connects network devices on a short distance. It is group of computers which all belong to same organisation or building. It links the devices in a single office, campus and building. 
In LAN the data transfer speed can reach up to 10 Mbps for an Ethernet network and 1 Gbps for Gigabit network. It can be reach as many as 100 or even 1000 users. 


MAN:-


MAN stands for Metropolitan Area Network.It is a network that interconnects users with resources in an area larger than that of LAN area but smaller than a WAN area. A MAN is made from switches or routes connected to one another with high speed links. It spread over an entire city.  


WAN:-


It is a geographically-dispersed collection of LANs. It is more larger than LAN and MAN network. The speed varies on WAN depending on the cost of the connection. Computer connected to a WAN network are often connected through public network like telephone system. They can also be connected through leased line and satellites. WAN provides a long distance transmission of data, video,voice and image information over large geographical area like a country, continent or even the whole world. Internet is the most well known WAN network





Define Networking?



What is Networking?


A network is a collection of computers, servers, and components. These allows for the easy flow of data and use of resources between one another. Networking is the practice of communicating two or more computers or devices for the purpose of sharing data. Networking helps the communication among multiple computers easily. With the help of computer networking the user access may be restricted when necessary. With the help of creating a network, devices like printers and scanners, files and data that are stored in the system can be shared.
In networking the communication language used by computer devices is called the protocol. Network implement multiple protocols for to support specific application. 



Which type of functions are performed by Data Transmission Software or Protocols?



Which type of functions are performed by Data Transmission Software or Protocol?

We know computers send and receive data across communication links. We use data communication software for it. The procedure of data transmission in the form of software is known as Protocol. The data transmission software or protocols perform the following functions for transmission of data.

  • Data Sequencing:- We break a large message into small and fixed size of packets for error free data transmission. 
  • Data Routing:- In data routing we search the most efficient route for sending data between source and destination.
  • Flow Control:- It makes the flow between fast sender and slow receiver for regulating the process of sending data. 
  • Error Control:- It is the main function for communication software for error detecting and recovering it. 


Give the difference between Array and Stack?




What is the difference between An Array And Stack?

  • An array is the collection of ordered elements and Stack is also ordered collection of elements. 
  • An array is a static object while Stack is dynamic size object. 
  • Array contains the same data types while Stack may contain different data type. 
  • In array the elements are removed in any order while in case of Stack, It follows the LIFO i.e the last element added to the stack will be the first one to be removed.
  • Array stored in random order while Stack stored in LIFO order. 
  • Both are Linear data structures but the array may be multi-dimensional or one dimensional while the Stack is strictly one dimensional. 

Define Non-Linear Data Structure and it's examples?




What is Non-Linear Data Structure. Define it?

The term Data means Values and Structure means the way it is organized and arranged into mathematical and logical way. So the mathematical and logical model of a particular organisation of data is known as Data Structures. 

Non-Linear Data Structure:-

The Data structure is said to be Non-Linear Data Structures if it's elements do not form a sequence or a linear series but form a hierarchical format.
For Example:- Graph, Tree, Binary Search Tree etc.

What is Graph?

Graph is a data structures which consists of a finite set of ordered pairs called edges . It is set of elements connected by edges. Each elements are called a vertex and node. 

What is Tree?

Tree is a widely used data structure in which elements are attached to one or more elements in a hierarchical order beneath it. The connection between the elements are called Branches.   

What is Binary Tree?

A Binary Tree is a special type of inverted tree in which each element has two branches below it. We can say that each node has at most two child nodes except the root node.

What is B-Tree?

A B-Tree is a tree data structure. It is a generalization of binary search tree in which a node can have more than two children. A B-Tree is designed to minimize the number of disk accesses. 

Define Linear Data Structure and it's examples?




What is Linear Data Structure. Define it?

The mathematical and logical model of a particular organisation of data is known as Data Structures. 

Linear Data Structure:-

The Data structure is said to be Linear Data Structures if it's elements are in a sequence and form a linear series.
For Example:- Array, Queue, linked list and Stacks.

What is Array?

Array is the collection of same data type elements under the same variable identifier referenced by index number. It is widely used in programming for the purpose of searching and sorting etc. 

What is Queue?

A queue is a linear data structure in which elements are removed in the same order they were entered. So the queue is the FIFO data structures. FIFO means first in first out i.e the first element added to the queue will be the first one to be removed. 

What is Stack?

Stack is the ordered collection of elements. It is a dynamic object whose size is continuously changing as elements are pushed or popped. In Stack elements are removed in the reverse order from which they were entered. This is referred as LIFO[Last In First Out]. It may contain different data type.

What is Linked List?

Linked list is the linear data structure which are used to organize data in a specific desired logical orders independent of the memory address each record assigned to it. 
It is a linear collection of data elements and the linear order is given by pointers. Each element [node] has two parts:- First part contain the information of the element and Second part contains the address of the next element [node] in the list.

Define Abstract Data Type?




What is Abstract Data Type. Define it?

Firstly I want to explain what is data type. Data type is a collection of values and set of operation on these values. When we store computer program's data in variables then each variables must be assigned a specific data type. Some data type are Strings, Array and float etc.
Abstract data type is a mathematical model for a certain class of data structures. It refers to the mathematical concept that define the data type. It can be regarded as a approach of a number of algebraic structures such as rings.  

Parts Of Abstract Data Type:-

There are two parts of Abstract Data Type as given below:-
  • Value Definition
  • Operation Definition

Define Data Structure and it's types?



What is Data Structure. Define it?

The term Data means Values and Structure means the way it is organized and arranged into mathematical and logical way. So the mathematical and logical model of a particular organisation of data is known as Data Structures. 
It is specialized format for organizing and storing data. It is also a particular way to store and organize data in a computer so that we can efficiently use it. We use data structures almost every program and software system. It provides us data efficiency such as large databases. 
A data structure may be designed to store data for working on it with various algorithms. 
Some common data structures are:-

  • Array
  • Linked List
  • Stack
  • Queue
  • Heap
  • Hash-Table
  • Tree:- Binary Tree
  • Red-Black Tree
  • B Tree

Types Of Data Structure:-

There are two types of Data Structures as given below:-
  • Linear Data Structures
  • Non Linear Data Structures

Linear Data Structure:-

The Data structure is said to be Linear Data Structures if it's elements are in a sequence and form a linear series.
For Example:- Array, Queue, linked list and Stacks.

Non-Linear Data Structure:-

The Data structure is said to be Non-Linear Data Structures if it's elements do not form a sequence or a linear series but form a hierarchical format.
For Example:- Graph, Tree, Binary Search Tree etc.

What is Malloc() function in C Programming Language?



What is Malloc() function in C Programming Language?

A malloc() function is used for  dynamic memory allocation. It is defined in stdlib.h or malloc.h depending on the operating system. Memory allocation by malloc() is persistent.  
  • void  *malloc(size_t size);


Example:

  • #include<stdio.h>
  • #include<stdlib.h>
  • void main()
  • {
  •           int array[10];
  •           int *ptr = (int *) malloc(10 * sizeof (int));
  • if (ptr == NULL)
  • {
  • }
  •           else
  •          {
  •                   free(ptr);
  •                   ptr=NULL;
  •           }
  • }

What is Calloc() function in C Programming Language?


What is Calloc() function in C Programming Language?


A calloc() function allocates space for an array of elements of a certain size and initializes the memory to zero. 

  • void  *calloc(size_t num, size_t size);
Here num is number of objects to allocate and size is the size of each objects. If the allocation is successful then function returns a Pointer to the first byte and if allocation fails then the function returns NULL. 

Examples:

  • #include<stdio.h>
  • #include<stdlib.h>
  • void main()
  • {
  •           unsigned a;
  •           int *ptr;
  •           printf(“Enter the number to allocate:-”);
  •           scanf("%d", &a);
  •           ptr= (int*) calloc(a, sizeof(int));
  •           if(ptr!=NULL)
  •           {
  •                      puts("Memory allocation successful");
  •            }
  •           else
  •           {
  •                     puts("Memory allocation failed");
  •           }
  •           return(0);
  • }


Output:-
  • Enter the number to allocate:- 200
  • Memory allocation successful
  • Enter the number to allocate:- 111111111111
  • Memory allocation failed

Define Null Pointer?


What is Null Pointer. Define it?


We use pointer in the programming language. It is the programming language data type. It's (pointer) value refers to directly another value which is stored elsewhere in the computer.
A Null pointer is a special pointer which is pointing to nothing. It has reserved value. It indicates the base address of the segment. We use Null pointer in the following ways:-



  • To stop indirection in a recursive data structure.
  • As a sentinel value.
  • As an error value.

Examples:-

  • int *ptr=NULL;
  • char *ptr=’\0’;
  • float *ptr=(float *)0;




  1. #include<stdio.h>
  2. void main()
  3. {
  4.           int a;
  5.           static int count;
  6.           for(a=NULL; a<=5)
  7.           {
  8.                   count++;
  9.                   a+=3;
  10.            }
  11.           printf(“%d”,count);
  12. }


Output:-
  • 4


  1. #include<stdio.h>
  2. void main()
  3. {
  4.           char *str=NULL;
  5.           strcpy(str, "Hello");
  6.           printf(“%s”,str);
  7. }


Output:-
  • Null (We can not copy anything in the Null Pointer).


Can we declare static variable Global in C Programming Language?



Can we declare static variable as Global in C Programming Language?

We can declare a static variable as Global and Local. There is some difference between declaring a variable as Global and Local. If we declare a variable as local then it can accessed only with in the function where it is declared in a program.
While if we declare a variable as Global then it can be accessed by all functions with in the program. 

Can static variables be declared in Header file in C Programming Language?


Can static variables be declared in Header file in C Programming Language?


We can not declare a static variable without defining it. We can declare static variables in header file when their definition should also be provided in the same header file. It is generally an idea to use static variables in the header file but it creates some problem that it makes the static variables as a private copy of header file i.e it can not be used elsewhere. 



What are the Storage Classes in C Programming Language?



What are the Storage Classes in C Programming Language?

A storage class tells us about the scope and lifetime of a variable or function with in a program. There are following Storage Classes in C:-

  • Automatic Storage Class
  • Static Storage Class
  • Register Storage Class
  • External Storage Class


Automatic Storage Class:-


The keyword for Automatic Storage Class is "auto". It is the default Storage Class for all local variables. If we declared a variable as auto then it is stored in the memory. The default value of this variable is garbage. The scope of this variable is local to block in which it is defined and it's lifetime will be remained till it's control will be with in the block. 


Example:-



  • #include<stdio.h>
  • void main()
  • {
  •           auto int var;
  •           printf(“%d”,var)
  • }



Output:-
  • 1045(Garbage Value)



Static Storage Class:-

The keyword for Static Storage Class is "static". It is the default Storage Class for global variables. If we declared a variable as static then it is stored in the memory. The default value of this variable is zero. The scope of this variable is local to block in which it is defined and it's lifetime will be remained till it's control will be with in the block. 

Example:-

  • #include<stdio.h>
  • static int var1;
  • int var2;
  • {
  •           printf(“%d”,var2)
  • }


Register Storage Class:-

The keyword for Register Storage Class is "register". It is used to define local variables and these local variables should be stored in register instead of RAM . If we declared a variable as register then it is stored in the CPU register. The default value of this variable is garbage. The scope of this variable is local to block in which it is defined and it's lifetime will be remained till it's control will be with in the block. 

Example:-

  • #include<stdio.h>
  • void main()
  • {
  •           register int var;
  •           printf(“%d”,var)
  • }

Output:-
  • 1045(Garbage Value)

External Storage Class:-

The keyword for External Storage Class is "extern". It is used to give reference to global variables that is visible to whole program files. If we declared a variable as extern then it is stored in the memory. The default value of this variable is zero. The scope of this variable is global(or local when it is defined with in block) and it's lifetime will be remained till as long as the program's execution does not finish.

Example:-

  • #include<stdio.h>
  • int var1;
  • void main()
  • {
  •           extern int var2;
  •           printf(“%d %d”,var1,var2)
  • }
  • int var2=20;

Output:-
  • 0,20


What is the meaning of Static variable in C Programming Language?


What is the meaning of Static variable in C Programming Language?

A static variable is a variable that has been allocated statically. A local static variable exists for the period of program but it is only visible in the function body. If the function is declared as static the it is invisible to outer files. If we use static global variable in the file then it is limited to with in the file. 

A program in C:-

  • #include <stdio.h>
  • int a = 10;  
  • main()
  • {
  •     int i =0
  •     void fun();
  •     fun();            
  •     printf("After First Call");
  •     fun();            
  •     printf("After Second Call");
  •     fun();            
  •     printf("After Third Call");
  • }
  • void fun()
  • {
  •     static int p=0;  
  •     int q = 10;             
  •     printf("value of p %d q %d",p,q);
  •     p=p+10;
  • }

Out Put of Above Program:-

After First Call:-      p= 0, q=10
After Second Call:- p=10, q=10
After Third Call:-     p=20, q=10


What are the disadvantages of C Language?


What are the disadvantages of C Language?


  • C has not constructor and destructor.
  • C has not the concept of Namespace.
  • C has not strict type checking.
  • C has not runtime checking.
  • C has not concept of Object Oriented Programming. These OOPs features are very important for regarding programming concept.
  • If the programs has large length then it is difficult to fix the bugs.
  • It is procedure oriented programming language, it is major problem.  

What are the advantages of C Language?



What are the advantages of C Language?

  • C is the basic language. It is the basis for development of other programming languages like C++, Java etc.
  • C programs are very fast and efficient then it is the advantage to save programmer's time.
  • C is simple and compact language.
  • C is flexible language so it provides easiness to programmer.
  • C is a portable language. It provides a high portability to take our software to one Operating System to other.
  • C has a lot libraries and these libraries provide easiness to programmers.
  • C is building block for other programming language. 

What are the characteristics of C Language?



What are the characteristics of C Language?

C is very popular language due to it's qualities and characteristics. Some of them are given below:-
  • C is popular for it's modularity characteristics. In it we can divided the large modules to small - 2 modules. It is very important in respect to give easiness to work.
  • Portability is also good characteristic. C language provides the portability. We can take or run our software anywhere due to it's portable nature.
  • C is structured Language.
  • C provides high speed to programmer because it is easy to write.
  • C provides the pointer functionality.
  • C can manage the low level activity.
  • We can compile the C programs in different -2 computers.
  • C provides the flexibility to programmers.
  • We can develop the efficient programs with the help of C.
  • C provides the extensive use of function calls.

Define C Language - What is C ?



What is C Programming Language?


C is a very popular programming language. It is standardized , structured and procedural programming language. 


It is developed by Dennis Ritchie between 1969 to 1973 in the Bell Laboratories. It is developed for use on the Unix Operating System.


Due to it's popularity it is used by many other Operating Systems. So it is one of the most widely used programming languages. 


C is used for writing System Software. It is also used for developing Application Software.