// Counting Elements
#include<stdio.h>
#define SIZE 10
void count();
int main()
{
int a[SIZE] = {'\0'};
int i,n;
printf("Enter the Number of Elements [Max = %d] : ",SIZE);
scanf("%d",&n);
if(n>SIZE)
{
printf("INVALID INPUT !! ");
}
else
{
for(i=0; i<n; i++)
{
printf("Enter the Elements a[%d] : ",i);
scanf("%d",&a[i]);
}
count(a);
}
return 0;
}
void count(int a[])
{
int i;
for(i=0;a[i];i++);
printf("\nTotal Number of Elements Are : %d",i);
}
#include<stdio.h>
#define SIZE 10
void count();
int main()
{
int a[SIZE] = {'\0'};
int i,n;
printf("Enter the Number of Elements [Max = %d] : ",SIZE);
scanf("%d",&n);
if(n>SIZE)
{
printf("INVALID INPUT !! ");
}
else
{
for(i=0; i<n; i++)
{
printf("Enter the Elements a[%d] : ",i);
scanf("%d",&a[i]);
}
count(a);
}
return 0;
}
void count(int a[])
{
int i;
for(i=0;a[i];i++);
printf("\nTotal Number of Elements Are : %d",i);
}
Comments
Post a Comment