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 |
Which is better malloc or calloc?
How can I pad a string to a known length?
What are the difference between a free-standing and a hosted environment?
What is pass by value in c?
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
What is a string?
What are the advantages of using linked list for tree construction?
Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......
How can you tell whether a program was compiled using c versus c++?
The C language terminator is a.semicolon b.colon c.period d.exclamation mark
different between overloading and overriding
what is the use of #pragma pack, wer it is used?