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


Please Help Members By Posting Answers For Below Questions

How is a structure member accessed?

581


write a program to copy the string using switch case?

2395


4. main() { int c=- -2; printf("c=%d",c); }

1364


What is the maximum length of an identifier?

659


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

647






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.

1527


What is identifiers in c with examples?

672


What are shell structures used for?

595


Difference between exit() and _exit() function?

651


What is pointer to pointer in c language?

593


What is the use of bit field?

632


What is the difference between %d and %i?

586


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

703


Can we initialize extern variable in c?

626


Tell me what are bitwise shift operators?

650