Bhanu Priya has Published 1449 Articles

Converting string to number and number to string using C language

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:55:43

1K+ Views

ProblemWhat do you mean by String to number and number to string conversion in C programming language?SolutionThere are two functions available for conversion. They are −sscanf() − convert string to numbersprintf () − used for converting number to stringString to number conversionWe can convert string to number using the sscanf() ... Read More

How to create a pointer for strings using C language?

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:47:32

2K+ Views

Arrays of pointers (to strings)Array of pointers is an array whose elements are pointers to the base address of the string.It is declared and initialized as follows −char *a[3 ] = {"one", "two", "three"}; //Here, a[0] is a ptr to the base add of the string "one" //a[1] is a ... Read More

Write a program to understand the concept of pointers in C language?

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:42:01

448 Views

Pointer is a variable which stores the address of other variable.Features of PointersFollowing are the features of pointers −Saves the memory spaceExecution time is faster because of direct access to memory location.The memory is accessed efficiently with the pointer i.e. dynamically memory is allocated and deallocated.Pointers are used with data ... Read More

Working with two-dimensional array at runtime in C programming

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:40:45

1K+ Views

ProblemWrite a C program to calculate sum and product of all elements in two-dimensional array using run time compilation.SolutionRuntime compilation or initialization is also called as dynamic allocation. Allocation of memory at the time of execution (run time) is known as dynamic memory allocation.The functions calloc() and malloc() support allocating ... Read More

What do you mean by Dynamic memory allocation in C programming?

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:39:33

13K+ Views

Dynamic Memory AllocationAllocation of memory at the time of execution (run time) is known as dynamic memory allocation.The functions calloc() and malloc() support allocating of dynamic memory.Dynamic allocation of memory space is done by using these functions when value is returned by functions and assigned to pointer variables.In this case, ... Read More

What do you mean by static memory allocation in C programming?

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:33:58

3K+ Views

Memory can be allocated in the following two ways −Static Memory AllocationStatic variable defines in one block of allocated space, of a fixed size. Once it is allocated, it can never be freed.Memory is allocated for the declared variable in the program.The address can be obtained by using ‘&’ operator ... Read More

How to assign a pointer to function using C program?

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:32:14

745 Views

Pointer to functionIt holds the base address of function definition in memory.Declarationdatatype (*pointername) ();The name of the function itself specifies the base address of the function. So, initialization is done using function name.For example, int (*p) (); p = display; //display () is a function that is defined.Example 1We shall ... Read More

Finding even and odd numbers in a set of elements dynamically using C language

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:31:18

1K+ Views

ProblemTo compute sum of even numbers and odd numbers in a set of elements using dynamic memory allocation functions.SolutionIn this program, we are trying to find even and odd numbers in a set of numbers.The logic used to find even numbers in a set elements is given below −for(i=0;iRead More

Explain dynamic memory allocation in C with an example

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:30:19

13K+ Views

ProblemFind the sum of n numbers entered by user using dynamically allocated memory using C programming.SolutionThe Dynamic memory allocation enables the C programmers to allocate memory at runtime.The different functions that we used to allocate memory dynamically at run time are −malloc () − allocates a block of memory in ... Read More

Post and Pre incremented of arrays in C language

Bhanu Priya

Bhanu Priya

Updated on 09-Mar-2021 08:28:40

5K+ Views

ProblemExplaining the array post and pre incremented concept with the help of C program.SolutionIncrement operator (++) −It is used to increment the value of a variable by 1There two types of increment operators − pre increment and post increment.Increment operator is placed before the operand in preincrement and the value ... Read More

Advertisements