-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment10_4.c
More file actions
48 lines (37 loc) · 891 Bytes
/
Assignment10_4.c
File metadata and controls
48 lines (37 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//4. Accept N numbers from user and return frequency of 11 form it.
#include<stdio.h>
#include<stdlib.h>
int Frequncy(int Arr[],int iLength)
{
int iCnt = 0,iCount = 0;
for(iCnt = 0 ; iCnt < iLength ; iCnt++)
{
if(Arr[iCnt] ==11)
{
iCount++;
}
}
return iCount;
}
int main()
{
int iSize = 0 , iRet = 0, iCnt = 0;
int *p = NULL;
printf("Enter number of elements \n");
scanf("%d",&iSize);
p = (int *)malloc(iSize * sizeof(int));
if(p==NULL)
{
printf("Unable to allocate memory");
return -1;
}
for(iCnt = 0; iCnt < iSize ; iCnt++)
{
printf("Enter element : %d\n",iCnt+1);
scanf("%d",&p[iCnt]);
}
iRet = Frequncy(p , iSize);
printf("Frequncy of 11 is : %d\n",iRet);
free(p);
return 0;
}