write a program in c to read array check element is present or
not?



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

Post New Answer

More C Interview Questions

Which is better malloc or calloc?

0 Answers  


How can I pad a string to a known length?

0 Answers  


What are the difference between a free-standing and a hosted environment?

0 Answers   Infogain,


What is pass by value in c?

0 Answers  


Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record

0 Answers   Wipro,


What is a string?

0 Answers  


What are the advantages of using linked list for tree construction?

0 Answers  


Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......

2 Answers  


How can you tell whether a program was compiled using c versus c++?

0 Answers  


The C language terminator is a.semicolon b.colon c.period d.exclamation mark

6 Answers   TCS,


different between overloading and overriding

3 Answers  


what is the use of #pragma pack, wer it is used?

2 Answers   Wipro,


Categories