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
Difference between exit() and _exit() function?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
How many bytes are occupied by near, far and huge pointers (dos)?
How can I split up a string into whitespace-separated fields?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
how to introdu5ce my self in serco
What are 'near' and 'far' pointers?
Why we use break in c?
write a proram to reverse the string using switch case?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
Differentiate between the = symbol and == symbol?
How are strings stored in c?
what are enumerations in C
What does it mean when a pointer is used in an if statement?
Write a program to reverse a given number in c language?