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
How can you restore a redirected standard stream?
What is a rvalue?
regarding pointers concept
What is scanf_s in c?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
Why c is called top down?
Write the Program to reverse a string using pointers.
Why do we need a structure?
What is difference between && and & in c?
Write a progarm to find the length of string using switch case?
i have a written test for microland please give me test pattern
What do you mean by keywords in c?
How macro execution is faster than function ?
What is the 'named constructor idiom'?
When is a null pointer used?