write a program in c to read array check element is present or
not?



write a program in c to read array check element is present or not?..

Answer / 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

More C Interview Questions

Write a program to print distinct words in an input along with their count in input in decreasing order of their count

0 Answers  


What is variable and explain rules to declare variable in c?

0 Answers  


What is array in C

0 Answers  


How can I write a function that takes a format string and a variable number of arguments?

0 Answers  


What is a example of a variable?

0 Answers  






who developed c and why he developed c?

5 Answers  


What is the relationship between pointers and data structure?

0 Answers  


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

0 Answers   Case, IBM,


How can you allocate arrays or structures bigger than 64K?

0 Answers  


Explain what are its uses in c programming?

0 Answers  


What is uint8 in c?

0 Answers  


How can I find out how much memory is available?

1 Answers   Persistent,


Categories