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
What is the hardest programming language?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
What is file in c preprocessor?
What is a string?
What is meant by inheritance?
What are the two types of functions in c?
How can you be sure that a program follows the ANSI C standard?
When is a “switch” statement preferable over an “if” statement?
Can stdout be forced to print somewhere other than the screen?
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
Explain pointer. What are function pointers in C?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What happens if header file is included twice?
what is uses of .net
Explain zero based addressing.