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
Is there any data type in c with variable size?
Write a program for finding factorial of a number.
What functions are in conio h?
What is string in c language?
How can you determine the size of an allocated portion of memory?
What is the symbol indicated the c-preprocessor?
Why double pointer is used in c?
What does void main return?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What are the 4 types of organizational structures?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What does 3 mean in texting?
Do you know the purpose of 'register' keyword?
What are # preprocessor operator in c?