Recently Added Questions & Answers

      Semester -    Subject -
 
 

==> STRINGS--

  • , array of character are called strings
  •  a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable

 

 

==> POINTERS--

  • A pointer is a variable which contains the address in memory of another variable.
  • Pointers are the variables that are used to store the location of value present in the memory

       Declaration :

                             data_type *variable_name;

                              Ex : int *a;

                  Ex :

                         #include int main()

                         {

                            int var = 20;

                            int *ip;

                            ip=&var;

                            printf(“Address of variable is %x ”, &var);

                            printf(“Address stored in ip variable is :%x”,ip);

                            printf(“value of *ip variable : %d”, *ip);

                            return 0;

                         }  

 

==> One Dimensional Array---

               Declaration::

                      Syntax: data_type array_name[array_size];

                                   where, data_type can be int, float or char.

                                   array_name is the name of the array.

                                   array_size indicates number of elements in the array.

                                   For ex: int age[5];

             Initialization::

                          Syntax: data_type array_name[array_size]={v1,v2,v3};

                                       where, v1, v2, v3 are the values

                                       For ex: int age[5]={2,4,34,25,18};

==> Two Dimensional Array----

             Declaration::

                            Syntax: data_type array_name[array_size][array_size];

                                          where, first index shows the row number of the element and

                                                         second index shows the coulmn number of the element

            Initialisation::

                             Syntax: data_type array_name[array_size][array_size]={V1,V2,V3,.....Vn};

                                           where, V1, V2, V3,......,Vn are the values

                             For ex: int matrix[2][3]={2,4,56,3,6};

 

DYNAMIC MEMORY ALLOCATION----

  •  It refers to performing manual management for dynamic memory allocation using standard library functions such as malloc, realoc, calloc and free.
  • The size of array initially declared can be sometimes insufficient or sometimes more than required but dynamic memory allocation allows a program to obtain more memory space, while running or to release space when not required.

FUNCTIONS OF DYNAMIC MEMORY ALLOCATION----

  • There are four standard library functions under “stdlib.h” for dynamic memory allocation. 
  1. malloc()
  2. calloc()
  3. realloc()
  4. free()             

=>   malloc() – It allocates requested size of bytes and returns a pointer first byte of allocated space.

                      Syntax : ptr=(data_type *)malloc(bysize);

                      Ex : (int*)malloc(100*sizeof(int)) 

=>   calloc() – Allocates spaces for array elements, initializes to zero and then returns a pointer to memory.

                      Syntax : ptr=(data_type*)calloc(n,element_size);

                      Ex : ptr=(float*)calloc(25,sizeof(float))

=>   realloc() – Changes the size of the previously allocated space according to the requirement.

                      Syntax : ptr=realloc(ptr,newsize);

=>   free() – It deallocates the previously allocated space.

                     Syntax – free(ptr);

Jump to Page : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

Recommended Question Bank

General - Computer Science
View
- Computer organisation and architecture
View
NA - Java
View
- javascript
View
- STORAGE AREA NETWORKS
View
Mejona - Mejona Technology
View
VTU - NCES(Non - Conventional Energy Resources
View
- Java Basic Codes
View
VTU - STORAGE AREA NETWORK
View
- HIGHWAY ENGINEERING
View
- COMPUTER ORGANIZATION
View
- Quantity Surveying and Contracts Management
View
- Design of RC Structural Elements
View
- Ground Water and Hydraulic
View
- Urban Transport Planning
View
- Basic Geotechnical Engineering
View
VTU - Municipal Waste Water Engineering
View
VTU - Design of Steel Structures Elements
View
- Interview Question Bank
View
VTU - Artificial Intelligence
View
Visvesvaraya Technological University (VTU) - Ground water hydraulic
View
-
View
VTU - Artificial intelligence and Machine Learning (AIML)
View
VTU - Energy and Environment
View
VTU - User Interface Design
View
- Data Structures and Algorithms
View
VTU - Big Data Analytics
View
VTU - Engineering Chemistry
View
VTU - User Interface Design (UID)
View
Entrance Exam for job - Entrance Exam Questions
View
VTU - Elements of Civil Engineering and Mechanic
View
VTU - Computer Graphics and Visualization
View
VTU - Object Oriented Concepts
View
VTU - System Software and Compiler Design
View
VTU - Web Technology and its Applications
View
VTU - Cloud Computing and Its Applications
View