Showing posts with label C language. Show all posts
Showing posts with label C language. Show all posts

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.

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 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.