0% found this document useful (0 votes)
33 views

Array

This C program counts the number of elements in an integer array called arr, which contains the elements 10, 20, 30, 40, and 50. It uses the sizeof operator to determine the total size of the array in bytes and divides it by the size of an integer to get the element count, which it stores in the variable n and prints out. The program then returns 0 to indicate it executed successfully.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Array

This C program counts the number of elements in an integer array called arr, which contains the elements 10, 20, 30, 40, and 50. It uses the sizeof operator to determine the total size of the array in bytes and divides it by the size of an integer to get the element count, which it stores in the variable n and prints out. The program then returns 0 to indicate it executed successfully.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

C program to count Array elements by using sizeof() operator.

#include <stdio.h>
int main()
{
int arr[]={10,20,30,40,50};
int n;

n=sizeof(arr)/sizeof(int);

printf("Number of elemenets are: %d\n",n);

return 0;
}

You might also like