-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram132.c
More file actions
59 lines (50 loc) · 1.01 KB
/
Copy pathprogram132.c
File metadata and controls
59 lines (50 loc) · 1.01 KB
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
49
50
51
52
53
54
55
56
57
58
59
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
bool Search(int Arr[],int iSize)
{
int iCnt = 0;
bool bValue = false;
for(iCnt = 0 ; iCnt < iSize; iCnt++)
{
if(Arr[iCnt] == 11)
{
bValue = true;
break;
}
}
return bValue ;
}
int main()
{
int iLength = 0,iCnt =0;
bool bRet = 0;
int *ptr = NULL;
printf("Enter the NUmber of the Element :\n");
scanf("%d",&iLength);
// Step 1: Allocate the memory
ptr = (int *)malloc(iLength * sizeof(int));
if(ptr == NULL)
{
printf("Unable to allocate memory");
return -1;
}
printf("Enter the element:\n");
for(iCnt = 0; iCnt < iLength; iCnt++)
{
scanf("%d",&ptr[iCnt]);
}
// Step 2: Use the memory
bRet = Search(ptr,iLength);
if(bRet == true)
{
printf("11 is present");
}
else
{
printf("11 is not present");
}
// Step 3: Free the memory
free(ptr);
return 0;
}