write a program in c to read array check element is present or
not?
Answer Posted / tatukula
#include<stdio.h>
int main()
{
char array[10]={0,1,2,3,4,5,6,7,8,9};
int check;
int i,flag=0;
printf("enter number you want to check in array\n");
scanf("%d",&check);
for(i=0;i<=sizeof(array);i++)
{
if(array[i] == check)
{
flag = 1;
break;
}
}
if(flag)
printf("element is present in the array\n");
else
printf("element is not present in the array\n");
}
input: 4
output: element is present in the array
input: 45
output: element is not present in the array
Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
How is a structure member accessed?
write a program to copy the string using switch case?
4. main() { int c=- -2; printf("c=%d",c); }
What is the maximum length of an identifier?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What is identifiers in c with examples?
What are shell structures used for?
Difference between exit() and _exit() function?
What is pointer to pointer in c language?
What is the use of bit field?
What is the difference between %d and %i?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Can we initialize extern variable in c?
Tell me what are bitwise shift operators?