Retrieve Data from an Array with char and double Type Data using the pointers - C Pointer

C examples for Pointer:Array Pointer

Description

Retrieve Data from an Array with char and double Type Data using the pointers

Demo Code

#include <stdio.h>

int main()//from w  w w . j a v  a  2s.co m
{
     char text[] = "book2s.com";
     double num[] = {1.2, 3.4, 5.6, 7.8, 9.11};
     printf("Values stored in elements of array text.\n");

     for (int i = 0; i < 5; i++)
        printf("Element no. %d, value: %c\n", i+1, *(text+i));
    
     printf("\nValues stored in elements of array num.\n");
     for (int i = 0; i < 5; i++)
        printf("Element no. %d, value: %.1f\n", i+1, *(num+i));
    
     printf("\nValue of array-name text: %u\n\n", text);
     printf("Addresses of elements of array text:\n");
     for (int i = 0; i < 5; i++)
        printf("Address of element text[%d] : %u\n", i, &text[i]);
    
     printf("\nValue of array-name num: %u\n\n", num);
    
     printf("Addresses of elements of array num:\n");
     for (int i = 0; i < 5; i++)
        printf("Address of element num[%d] : %u\n", i, &num[i]);
    
     return(0);
}

Related Tutorials