Array in c

union A{
    char character;
    int ascii;
int main(){
    union A arr[2]={{65},{'a'}};
    printf("%c %c",arr[0],arr[1]);
return 0;



Output: A a
(d) Array of structure
 An array which can hold address of structure data type is known as array of structure. For example:

(1) What will be output when you will execute the following program?#include<stdio.h>

typedef struct stu{
    char * name;
    int roll;
int main(){
    s arr[2]={{"raja",10},{"rani",11}};
    printf("%s %d",arr[0]);
    return 0;
Output: raja 10



(2) What will be output when you will execute the following program?#include<stdio.h>

struct A{
    int p;
    float q;
    long double *r;
int main(){
    struct A arr[10];
    printf("%d",sizeof arr);
return 0;



Output: 80
(e) Array of string
    An array which can hold integer data type is known as array of integer.
(f) Array of array
    An array which can hold address of another array is known as array of array.
(g) Array of address of integer
    An array which can hold address integer data type is known as array of address of integer.
Pointer to array

A pointer which holds base address of an array or address of any element of an array is known as pointer to array. For example:


int main(){
    int arr[5]={100,200,300};
    int *ptr1=arr;
    char *ptr2=(char *)arr;

    printf("%d   %d",*(ptr1+2),*(ptr2+4));return 0;

Output: 300   44
int main(){
    static int a=11,b=22,c=33;
    int * arr[5]={&a,&b,&c};
    int const * const *ptr=&arr[1];
    printf("%d ",**ptr);
return 0;


Output: 11

int main(){
    int ax=1;
    int b=2;
    int cg=5;
    int dff=7;
    int am=8;
    int raja=0;
    int rani=11;
    int xxx=5;
    int yyy=90;
    int p;
    int q;
    int r;
    int avg;

    printf("%d",avg);return 0;

int main(){
    int arr[]={1,2,5,7,8,0,11,5,50};
    int i,avg;
    for(int i=0;i<12;i++){
return 0;



Related posts:

About author

This article was written by admin

Admin has over twenty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles. Working presently as Development Manager in India. A firm Believer in Knowledge grows when it shared.


Comments (3)
  1. SBOBET says - Posted: October 24, 2012

    I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet smart so I’m not 100% certain. Any tips or advice would be greatly appreciated. Thank you

  2. kasyno darmowe says - Posted: October 24, 2012

    In what exactly web host lies your web site? Due to the fact I really do not need extremely high rate world wide web, nonetheless it load in a few just a few seconds! Time to share learn when you can; )

  3. Young Lail says - Posted: October 24, 2012

    Simply desire to say your article is as amazing. The clarity in your post is simply nice and i could assume you’re an expert on this subject. Well with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the rewarding work.

Leave your comment

Your email address will not be published. Required fields are marked *