C Program to display array elements with addresses : [crayon-638cf64a5338b546727258/] Output : [crayon-638cf64a53396427849386/]
Stack operations can be implemented using the pointer in easy manner. This article will explain you everything about the stack using pointer.
Program to Calculate Length of the String using Pointer Write a C Program which will accept string from the user . Pass this string to the function. Calculate the length of the string using pointer. Program : Length of the String using Pointer [crayon-638cf64a54e86927008462/] Output : [crayon-638cf64a54e8c851881801/] Explanation : gets() is used to accept string with spaces. we are passing accepted string to the function. Inside function we have stored this string in pointer. (i.e base of the string is stored inside pointer variable). Inside while loop we are [...]
Write a C program using pointers to read in an array of integers and print its elements in reverse order. [crayon-638cf64a5539f413120286/] Output : [crayon-638cf64a553a6602917687/] Program to read integers into an array and reversing them using pointers Explanation : We have declared one pointer variable and one array. [crayon-638cf64a553a9256391057/] Address of first element of array is stored inside pointer variable. [crayon-638cf64a553ad341067683/] Accept Size of an Array. [crayon-638cf64a553b0279743600/] Now we have accepted element one by one using for loop and scanf statement . [crayon-638cf64a553b3843811314/] Increment pointer variable so that it will then point to [...]
Program : How to Add Two Numbers Using Pointer ? In this program we are going to accept two numbers from user using pointer. After accepting two numbers we are going to add two numbers by using de-reference operator in Pointer. [crayon-638cf64a5572c237914186/] Output : [crayon-638cf64a55732918712895/] Note : Value Filed of Pointer Can Be Accessed Using '*' Operator '*' is value at Operator. Read '*ptr' as 'Value at Address ptr'.