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


Please Help Members By Posting Answers For Below Questions

How can you restore a redirected standard stream?

612


What is a rvalue?

755


regarding pointers concept

1579


What is scanf_s in c?

635


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1499






Why c is called top down?

631


Write the Program to reverse a string using pointers.

620


Why do we need a structure?

590


What is difference between && and & in c?

602


Write a progarm to find the length of string using switch case?

1614


i have a written test for microland please give me test pattern

2186


What do you mean by keywords in c?

632


How macro execution is faster than function ?

671


What is the 'named constructor idiom'?

643


When is a null pointer used?

644