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 |
What is the description for syntax errors?
How can I use a preprocessorif expression to ?
Do you know what is the purpose of 'extern' keyword in a function declaration?
How is pointer initialized in c?
how to create duplicate link list using C???
Add Two Numbers Without Using the Addition Operator
Is it possible to initialize a variable at the time it was declared?
A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above
Explain can you assign a different address to an array tag?
Can a program have multiple main() functions?
When should a type cast not be used?
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;