Monday, 27 October 2014

Size of Array

Non-Recursive C Program:

Aim:
To find size of an array.

Program:
#include <stdio.h>
int main( )
{
   int i,num;
printf("\nEnter the hoe many elements you want?\n"); scanf("%d",&num);

int a[num];
printf("\nEnter the %d elements:\n",n um);
for(i=0;i<num;i++)
  {
    scanf("%d",&a[i]);
   }
printf("Elements in array are:\n");       for(i=0;i<num;i++)
{
   printf("%d\n",a[i]);
  }

printf(" The size of the array is: %d Bytes.",(int)sizeof(a));

return 0 ;
}

No comments:

Post a Comment