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

Can a variable be both static and volatile in c?

0 Answers  


Are there namespaces in c?

0 Answers  


how to construct a simulator keeping the logical boolean gates in c

0 Answers  


fn f(x) { if(x<=0) return; else f(x-1)+x; }

5 Answers   HCL,


What is difference between union All statement and Union?

0 Answers  


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

0 Answers  


What is the Lvalue and Rvalue?

2 Answers  


Hi can anyone tell what is a start up code?

0 Answers   CTS,


Difference between null pointer and dangling pointer?

7 Answers   GE, Wipro,


Define circular linked list.

0 Answers  


write a program to add two numbers of any size.....(remember any size)

1 Answers  


Can stdout be forced to print somewhere other than the screen?

0 Answers  


Categories