-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram11_1.c
82 lines (60 loc) · 1.35 KB
/
program11_1.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// 1. Accept N numbers from user and accept one another number as NO ,
// check whether NO is present or not.
#include <stdio.h>
#include <stdlib.h>
typedef int BOOL;
#define TRUE 1
#define FALSE 0
BOOL Check(int Arr[],int iLength, int iNo)
{
int iCnt = 0 ;
for ( iCnt = 0; iCnt < iLength; iCnt++)
{
if (((Arr[iCnt] ) == iNo) )
{
break;;
}
}
if(iCnt == iLength)
{
return FALSE;
}
else
{
return TRUE;
}
}
int main()
{
int iSize = 0, iCnt = 0;
int iValue = 0;
BOOL bRet = FALSE ;
int *p = NULL;
printf("ENTER Number of Elements : ");
scanf("%d",&iSize);
printf("ENTER Number for search : ");
scanf("%d",&iValue);
p = (int *)malloc(iSize * sizeof(int));
if (p == NULL)
{
printf("Unable to allocate memory !!!");
return -1;
}
printf("ENTER The %d Elements \n",iSize);
for ( iCnt = 0; iCnt < iSize; iCnt++)
{
printf("Enter %d Elements : \n",iCnt + 1);
scanf("%d",&p[iCnt]);
}
bRet = Check(p, iSize,iValue);
if (bRet == TRUE)
{
printf(" Number is present ");
}
else
{
printf(" Number is absent ");
}
free(p);
return 0;
}